fix compiler warnings

changed for loop to while loop, fixes compiler warnings about no body
for the loop.