Need help getting a program to loop

well not if index is calculated based on that variable, right?

Yes, you are correct.