Add error detection to Read_into_buffer