$readn is 0 if no match found, but if there are 2 entries in the text, $readn will be 0 after the while.
$v1 contains the last test value of the while, but that is always $false after the while (else the while loop wouldn't have ended)
$ifmatch is deprecated and should be replace by $v1 in new scripts. I also changed some of the code to make it less lines, and made the counter start at 0, you'll see why right away smile
Best option is to check the loop counter: if %i > 0 then the loop has passed one time...

Code:
on *:TEXT:!search *:#p: {
  msg # 7:: Limit of 5 results
  var %line = 0,%i = 0
  while ((%i < 5) && ($read(nick.txt,nw,$+(*,$$2-,*),%line))) { 
    msg # 7:: 11[10MA7T10CH11]7 $v1
    var %i = %i + 1, %line = $readn + 1
  }
  if (!%i) msg $chan Nothing found...
}