Fix variable mix-up in increment (loop uses j, but increments i).

This caused an infinite loop.