Delete files before writing to prevent certain permission problems