working on buffered write