corrected the read and write by updating the f_pos