added some error handling if the file cannot be deleted