close loose file handle in writeFileAtPath