Fix infinite loop

This goes into an infinite loop when `i` is not incremented. It happened while reducing some private D1 code, so I can't give you a test-case sadly. Does this look ok to you now?