Your LED is probably blinking but you can't see it because the frequency is very high.
Adding the print call adds a delay greater than the while loop, so the frequency decreases to a "visible" range.
Make this test: force the LED always on and you'll see a higher light intensity.
While or for loops are a deprecated method to implement delays; besides the dependence on cpu speed, they are strongly affected by compiler optimizations. Some hard optimized compilers would even remove loops which have no functional side effect, like in your case.
Using a timer would be a better solution.