Getting the loop but cannot get the index to increment by one