Refactored the code in order to not assign to the loop counter from within the loop...