well,
as I said before, you probably want to do a preg_match_all for optimum performance.
but, since you want line by line...
// exec the code I handed you before.
// here you file() away
$lines = file($last);
for ($i=count($lines);$i>0;$i--) {
if (preg_match('/(expression)$/is',$lines[$i-1])) {
//do something...
}
}