For loop and while loop debugging of code that caused infinite loop.