Check if tmp file exists before deleting and using uuid for naming