A global variable cannot be used as a loop variable. Redefine the variable to be local to the loop, or use another (local) variable as the loop variable.