in reply to &process or die

My gut feeling is that the open call is failing and you're seeing the result in a failed close that returns to your loop and dies. Check the return of open...

open my $OUTFILE, q{>}, $outfile or die "failed to open $outfile: $!";

On another note, you can use the path and skip the chdir calls. e.g.

my $OUTFILE, q{>}, "$path_to_the_data_directory/$outfile" or die "failed to open $path_to_the_data_directory/$outfile: $!";