resetting the counter for the iov array has to happen outside of the if statement.