Make sure to delete the output file in case of an exception.