if writeToFile succeeded the file needs to be deleted. Not on failure.