Replace a for-range loop by a while loop in javalib.

It was on the path of Predef.println(), which is worth
making not too slow. Besides, it was the only for-range
loop in javalib.