Fix error handling in parse_file