Unlike most command line programs the order of the options make a difference. The thing to remember is that blender executes each option in the order they are given, almost like a mini script.
The command you used blender --python-text my_text_block_name scene.blend
says run this text block then open this file.
To get your example working you want to open the blend file then execute the text block - blender scene.blend --python-text my_text_block_name
More details about Blender commandMore details about Blender command and some example of how order worksexample of how order works.