open my $wfh, '>', "$dir/$input" or die "can't open the damned output file! $!";