Scripting: Converting Text object to Mesh object fails due to incorrect context (2.78)
bpy.ops.wm.read_homefile() - kills your current file and causes the trouble. If you could avoid it, it will work. I think you can import a scene from some blend file instead.
Look also this thread, and this.