Ensure all file system access is wrapped in error handlers to close file handles