Error Message Interpreter Mode

Hello,
I tried to send commands to my robot UR10e by using the interpreter mode.
This worked quite well for Scripts that used only the move command.

for example:
movej(get_inverse_kin(Wegpunkt_2_p, qnear=Wegpunkt_2_q), a=1.4, v=1)
movej(get_inverse_kin(Wegpunkt_1_p, qnear=Wegpunkt_1_q), a=1.4, v=1)
movej(get_inverse_kin(Wegpunkt_2_p, qnear=Wegpunkt_2_q), a=1.4, v=1)

Of course I declared the Wegpunkte.

Now I want to use for and while loops like this:
while (True):
movej(get_inverse_kin(Wegpunkt_2_p, qnear=Wegpunkt_2_q), a=1.4, v=1)
movej(get_inverse_kin(Wegpunkt_1_p, qnear=Wegpunkt_1_q), a=1.4, v=1)
movej(get_inverse_kin(Wegpunkt_2_p, qnear=Wegpunkt_2_q), a=1.4, v=1)
end

But I keep getting this error:
interpreter mode “universal robot” Exception: (‘Interpreter discarded message’, 'discard: Syntax error on line 4: end: def

What could be my mistake? I already tried using another variable for the while loop, this doesn’t work either.

Thank you for your help!