read_line: free the buffer if no line has been read