/help /write
/help $address
Basically, you'd end up with:
/write filename.txt $address($nick,2)
or something similar, depending how much of the address you'd like (/help $mask). You'd then put that line into some event depending on where you'd like it to happen. For example, if you want it to be done when they join, then check /help on join ....
on *:join:#: { write filename.txt $address($nick,2) }