Handler-script updates in viewport but not in render I'm completely stuck :-/ 

I've made a handler-script, that takes with every new frame a new line from the 
text-editor and puts that line into the text-object in 3d-space.
It works absolutely fine - but when I want to render it, is it not working any more.

Why is that?? Other handler scripts from me are working fine... 

import bpy

'''Text-Objekt muss angewählt sein und im Object-Mode
##################################################'''

def Text_Line_by_Line(Scene):

    FrameNumber = bpy.context.scene.frame_current - 1 #aktuelle Frame-Nummer minus 1 weil python 1 = 0

    TextFile = bpy.data.texts['Text'] #&lt;------------Text-Name eingeben
    TextLine = TextFile.lines[FrameNumber].body  # Nimmt die Text-Line als String

    bpy.ops.object.editmode_toggle() 
    # Vorherigen Text löschen
    bpy.ops.font.select_all() #selektieren
    bpy.ops.font.delete()   #löschen

    bpy.ops.font.text_insert(text=TextLine)  #Fügt den Text ein

    bpy.ops.object.editmode_toggle()

bpy.app.handlers.frame_change_pre.clear()
bpy.app.handlers.frame_change_pre.append(Text_Line_by_Line)
Don't use operators in handlers

For the most part don't use operators in handlers. When rendering for example, the context needed will not be there.  I imagine edit mode toggle means nada to the renderer.
Use API methods and the passed argument scene
In example below, displays a line of bpy.data.texts[&quot;Text&quot;] as the body of text object scene.objects[&quot;Text&quot;]
import bpy

# pass arguments to build a handler
def text_body_handler(obname, textname):
    # the handler method
    def text_body(scene):
        text = bpy.data.texts.get(textname)
        text_ob = scene.objects.get(obname)
        if not text and text_ob:
            print(&quot;Error: check names&quot;)
            return 
        f = scene.frame_current
        lines = len(text.lines)
        if text_ob and f &lt;= lines:
            text_ob.data.body = text.lines[f-1].body
 
    return text_body

bpy.app.handlers.frame_change_post.clear()           
bpy.app.handlers.frame_change_post.append(text_body_handler(&quot;Text&quot;, &quot;Text&quot;))

Textblock bpy.data.texts[&quot;Text&quot;]
I had written him a letter 
which I had, 
for want of better Knowledge, 
sent to where I met him 
down the Lachlan, years ago,
He was shearing when I knew him, 
so I sent the letter to him,
Just ‘on spec’, addressed as follows,
‘Clancy, of The Overflow’.