in reply to while (<FH>) always ends with "Couldnt read from remote file: End of file at"

You haven't shown the appropriate code to reproduce the issue, and the following works fine for me:

use warnings; use strict; use Data::Dumper; use Net::SFTP::Foreign; $Data::Dumper::Useqq=1; die "Usage: $0 SSH_HOST\n" unless @ARGV==1; my $sftp = Net::SFTP::Foreign->new($ARGV[0]); $sftp->die_on_error("Unable to establish SFTP connection"); my $fh1 = $sftp->open("/etc/passwd") or die $sftp->error; while (<$fh1>) { print Dumper($_) if /root/ || /wheel/ || /www/; }

To get better help, register an account so that you can edit nodes if necessary (instead of posting several disjoint anonymous nodes) and show a Short, Self-Contained, Correct Example that reproduces the issue - for example you don't show how you create the $sftp object (I have to guess that it's an Net::SFTP::Foreign), and you don't tell us which line is 96. See also How do I post a question effectively?