Code:
on @*:text:@find &:#mychannel: findlines temp.txt $2 5
 [color:red]  [/color] 
alias findlines {
  var %tmp = $+($ticks,.txt)
  filter -ff $1 %tmp $+(*,$$2,*)
  if ($filtered) {
    if ($ifmatch > $3) filter -ffcr $+(1-,$3) %tmp %tmp
    .play -n $nick %tmp
  }
  else notice $nick No matches for $2
  .remove %tmp
}


You could also use the file handling commands, in this particular case they could even be faster than using /filter, since you have a limit to the number of results you want returned. The code is somewhat longer though, and the speed will be relatively neglectible, you wouldn't notice it.