fix file copy, open mode for target file were set incorrectly.