Fixed file creation code