changed read and write int to buffered