Buffered reading and writing