reading into the buffer and closing the file.