Fixed a bug: output row index wasn't reset with each chunk.

When the output row index exceeded the BUFFER_SIZE the row index
wasn't getting reset to 0 on each iteration over an output chunk,
resulting in an IndexError at runtime.