my $LastLine=''; while(my $Line=<$logfh>) { if(index($Line,$Variable)>-1) { print "$Line$LastLine
\n"; push(@ErrorList,$LastLine,$Line); } $LastLine=$Line; }