added error handling for the "file" command