If exception occurs make sure we still delete the temp file.