lib: Use iov_advance in write_data_iov