Look for:

Code:
      if ($lines(quotes.txt) < $2) { msg %who Quote # $+ $2 doesn't exist. | return }
      msg %who $read(quotes.txt,$2)


Put that in an ELSE statement:
Code:
      else {
        if ($lines(quotes.txt) < $2) { msg %who Quote # $+ $2 doesn't exist. | return }
        msg %who $read(quotes.txt,$2)
      }


The way you have it, that IF will be wrong if $2 isn't a number, so you don't want it to happen if you searched for a word.