write files to output dir if exists