```index``` is not the same as ```i```, ```i``` is counter used specifically to prevent the infinite loop.