Sorry for the repeat posts, just been reported a critical error in it so found and fixed it. I put a extra if condition inisde a while loop and encased the dec %i of the while counter inside the condition, oooops!

Code:
on @*:TEXT:*:#: {      
  if ($nick !isop #) {     
    tokenize 32 $strip($1-)
    ;
    ; ******************************************************************************
    ; *** Phase 1 : check if any of the swear words appear in the text as words. ***
    ; ******************************************************************************
    ;
    var %nicktext                                                                                | ; *** see below for phase 1 option (0)
    ;var %nicktext = $1-                                                                          | ; *** see below for phase 1 option (1)
    ;var %nicktext = $remove($1-,$chr(32))                                                        | ; *** see below for phase 1 option (2)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,,%nicktext) | var %nicktext = %nicktext | ; *** see below for phase 1 option (3)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Za-z]+/g,,%nicktext)  | var %nicktext = %nicktext | ; *** see below for phase 1 option (4)
    ;
    ; * Please select only one of the above four lines remark out with a ; the other three you do not want. See below for explanation.
    ;
    if ($len(%nicktext)) {
      var %swearwords = $$read(swear.txt,nt,1)
      var %i = $numtok(%swearwords,32)
      while (%i) {
        var %badword = $gettok(%swearwords,%i,32)
        if ($+(*,%badword,*) iswm %nicktext) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - %badword }
          if (%rl. [ $+ [ $address($nick,2) ] ] >= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - %badword }
          return
        }
        dec %i
      }
    }
    ;
    ; ********************************************************************************************************************
    ; *** Phase 2 : Assume any non alpha is a character holder and search for matching words. ie "sht typed as "sh!t" ***
    ; ********************************************************************************************************************
    ;
    var %swearwords = . $$read(swear.txt,nt,1) .
    var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,*,%nicktext) | var %nicktext = %nicktext 
    var %i = $numtok(%nicktext,32)
    while (%i) {
      var %nickword = $gettok(%nicktext,%i,32)
      if (%nickword != *) {
        if ($(* %nickword *) iswm %swearwords) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - $ [ $+ [ %i ] ] }
          if (%rl. [ $+ [ $address($nick,2) ] ] >= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - $ [ $+ [ %i ] ] }
          return
        }
      }
      dec %i
    }
  }
}
;
;
;Phase 1 %nicktext is the source text the nick says, how you wish to pharse it is your choice, see below for whats likely to occur.
;Assume "sht" is a bad word                                ::: text  "u shts"  "u s h i t s"  "u s-h-i-t-s"  "thrash its"  "thrash! Its"
;Option(0) : Phase 1 disabled                               ::: Catch     N              N             N             N             N (default)
;Option(1) : plain text                                     ::: Catch     Y              N             N/y*          N             N
;Option(2) : accumulated plain text (spaces removed)        ::: Catch     Y              Y             N/y*          Y             N
;Option(3) : alpha text (remove non alphas except space)    ::: Catch     Y              N             Y             N             N
;Option(4) : accumulated alpha text (remove all but A-Za-z) ::: Catch     Y              Y             Y             Y             Y
;
; Note on Items marked with a /y* above, While these are not acctually caught here they are caught by phase two, so may be deemed as Y
;
;
;Phase 2 removes any one or more continuous non alpha except space replacing them with one * (which represents 0 or more characters in ISWM)
;"u sht"     -> "u sht"
;"u s h i t"  -> "u s h i t"
;"u s-h-i-t"  -> "u s*h*i*t"
;"thrash it"  -> "thrash it"
;"thrash! It" -> "thrash* it"
;"you s%%t!"  -> "you s*t*"
;Each word is then checked for a word boundry wildmatch into the list of swearwords, with "s*h*i*t" and "s*t*" being matched
;
;