so sometimes when i run this code, it goes into an infinate loop and i cannot figure out why. can someone help me?
while loop on line 16 will never exit as its condition will never be invalidated:
counter is never modified inside of it. You should indent line 32 so that it is inside the loop.