Too many uses of the word index
Don't confuse the counter variable named index with the concept of using a numeric index to access an element in an array.
Aside from the fact that the value of the counter variable is being used as the value of the numeric index, they have nothing in common even though they have the same name.