This part may fail if TMPDIR does not exists or you don't have permission to write to it. Code should check and be protected against such failures