Fixed read_file function