Properly closes the file in add_file()