parse_file: close file when error