saving offset after writing data not before