1. You really want to use
$fline instead of a while loop/iswm: it makes a big difference speed-wise in large channels.
2. I don't see why you use
if (a iswm b) { .. }
elseif (a !iswm b) { ... }
instead of
if (a iswm b) { ... }
else { ... }
No reason to make the script slower by checking the same condition twice.
3. I assume the "elseif" part is meant to decorate any nicks in $1- with ~'s, however it's not correct: it will only decorate any occurrences in $1- of the first nick in the channel (assuming $1 doesn't match) and then stop.
4. Using $replace to replace all occurrences of a nick in $1- will likely lead to problems with short/common nicks. Consider what would happen with a nick like "hi" or "att": words like "this", "him" or "attention", "pattern" etc would be messed up.
5. If my assumption in #3 is correct, you do need a loop, but not through the nicklist; rather through the words in $1-, checking
if ($N ison #)