Why does the engine think this is an infinite loop despite there being a while(!=) condition?

The delay has no effect in a while loop, so you’re effectively running at full tilt there…

You’d be better off using the timer I see there. All it’s doing at the moment is adding a 3 second delay.

Something like this ( cut down version ):