Use shutil for file write.