Like Riamus2 said, you should use some protection and also, a while isn't a good idea in this case, /filter is better :

on *:text:search *:?:filter -c filename.txt o.txt $+(*,$2-*) | play $nick o.txt | if ($exists(o.txt)) .remove o.txt




#mircscripting @ irc.swiftirc.net == the best mIRC help channel