DO WHILE NOT k: IF k THEN EXIT DO:LOOP
Isn't the above only 2 lines of code?
DO WHILE NOT k
IF k THEN EXIT DO:LOOP
Since the LOOP is right of the IF..THEN, then it's part of the IF statement, leading to the program flow error.
For example:
X = 1: Y = 2
IF X = 1 THEN X = X + 1: Y = Y + 1
PRINT X, Y
The above prints 2, 3, as the one IF condition changes both values. Initialize X to 0, and Y won't change... You just have a compound single-line IF statement to parse..
Seems to me that everything is working as it should here.