Ensure that the imported file is closed if any errors occur in import.