writing out file to dest