fix a bug in write_stream where offset were not updated