/help on join
/help /write

Individual lines:
Code:
on *:join:[color:red]#yourchannel[/color]: {
  write nicks.txt $nick
}


Commas:
Code:
on *:join:[color:red]#yourchannel[/color]: {
  write -al1 nicks.txt $nick $+ ,
}


Just a warning with using commas on a single line... mIRC doesn't easily deal with really long lines. If this is something that you want mIRC to work with, you'll be much better off using individual lines.