When you change value of a variable in a loop, its value will be what the last change was. Any previous changes will have been forgotten. Sort of like:
x = 1;
x = 4;
x = 2;

the 4 and 1 are...