fixed fn to write files to a tmp dir.
made writeNewFiles to write contents to tmp dir