Congrates, while your method may seem to some to be odd in that you save to a window then save the window to a file, it may infact be better than what i suggested, as Im not to sure how mirc adds lines to a file using /write, it may copy the entire file to a new copy and add the line, this would be disk intensive, while your script simply uses memory then writes the whole lot at once.

Only thing ill say and its a real minor thing, try out using " .echo -q " instead of " var %a = ", -q means dont echo if .echo was used. So it never shows.