in reply to removing lines that are in the end of a file

In your loop over the lines of each file, you say

while( my $line = <FILE> ) { chomp($line); if( $line =~ / SIL$/ ) { print $line, "\n"; last; } }

UPDATE: Removed ~ in assignment to $line, thanks to Loops!