in reply to Re^2: Loop is not working
in thread Loop is not working

This is a huge guess here, but I feel that this is due to a #define ENOENT 2 /* No such file or directory */ that may have been encountered.

You may be in a directory that you think you are but aren't, or possibly trying to work on a file from a location where it doesn't exist. Can you change:

system($program,$outfile) == 0 or die "$program $outfile failed: $?";

...to:

print -x $program . "\n"; open my $fh, '<', $outfile or die $!;

...within the exact same code and see if you get an error?