I suppose it comes from the "Dijkstra puzzle", right? I tested the project with both 1.2.44 and 1.3.x with the same results...
If you remove the Sleep() command, the entire while cycle is performed at once. The Sleep command, on the other hand, returns control to the engine and all the other scripts are executed and screen refresh is done before the while cycle is executed again. Could that be the difference?