Reuse of $i was causing infinite loop
Merge pull request #325 from tklever/hotfix-infinite-loop

Reuse of $i was causing infinite loop