Write ENDIF in line 132, 135 and 138.
When THEN is followed by carriage return directly, you need ENDIF at the end of IF THEN suite.
When you write IF THEN suite in a line, you don't need ENDIF.
Like Hanzo says, your IF statements need an ENDIF. If your entire IF is on a single line like this:
IF A THEN B
then it ends at the end of that line. But if it's like this, it needs an ENDIF or everything after the IF is inside it:
IF A THEN
B
ENDIF
Because of that, in your program, everything after line 130 is actually inside that IF, including the UNTIL, which is why it breaks.