This `i` is a little far from the while loop that actually uses it. Maybe it is better to define it just before `while`.