I have been looking at this code for 20min and I can't understand why this loop is infinite, it should print 30 elements.
Some text, because post is mostly code.
I'm guessing it's because if (i = 1)
assigns 1
toi
. You meant to compareif (i == 1)