use warnings; use strict; my $fh = open '<', 'Test1.txt' or die "can't open the damned file!: $!"; while (<$fh>){ chomp; # this will remove the newline from $_ print "I saw $_ in the file\n"; }