I think that is an error.
var %w = 1
while ($gettok(%badwords, %w, 32))

If you don't increase the %w variable, the script check only first word of the string %badwords.
Is this correct?