The ESP8266 has additional code that needs to run between iterations of the loop function. If you are going to trap it elsewhere in some while loop, then you need to also be sure to call delay(0)delay(0); or yieldyield; in there so that it can handle its other business. If the code around loop doesn't get run in time, then the board resets from the watchdog IIRC. I believe that is the symptom you are seeing.
And like the others say, there is no googood reason for a blocking loop in your code. Let the loop function be the loop.