fixed file creation code broken by 'dir' to 'dirpath' update