added O_EXCL flag to file creation in copy_file()