If you actually want to handle this case; you should delete the file in case write failed.