Sorry for bring up an older topic. After testing the last code you suggested, DaveC, intermixed with code of my own, giving the following
Code:
 alias line.correct {
  var %file = $findfile(c:\,Observer 2.csv,1), %a = 1, %b = $lines(%file)
  while %a <= %b {
    var %data = $read(%file,nt,%a)
    if $numtok(%data,44) < 11 {
      %data = $replace(%data,$+($chr(44),$chr(44)),$chr(44) $chr(44),$+($chr(44),$chr(44)),$chr(44) $chr(44)) 
    }
    .write -l $+ %a %file %data
    inc %a
  }
  echo -a Complete
}
 

and then checking the lines manually, I found that the replacements are not being written. Now I admit this may be a problem with the /write command, rather than the usage of the $replace, but I don't think so.

Any suggestions/recommendations?