I'd still like to get rid of $s and $d
system("cp $dir/$file $dir/$NextOut/$file");
But they are needed for use in the following diagnostic line:
print "$s->$d\n";
continued...