fix in read() and write()