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.