Lines 29-31: You reset your loop variable to 0. How do you ever expect to reach the termination condition on line 11 (i<5)?
Line 11: It's poor style to assume i was properly initialized. You should use the beginning condition (i=0) to assure that i is reset to 0 each time through the outer while loop. I'm assuming this is what you we trying to do (incorrectly) with lines 30-32.