Yes, if you use $chan as the topic name, it will pick the channel that the event has triggered.
For the file, you can specify a full path like, D:\MyFolder\my.ini, if you don't specify the path and just write the filename, it will use the root directory of your mIRC.
Pleae note that if the path that you write for the file contains SPACE you have to use quotation (which is $qt) or Short filename (which is $shortfn) otherwise your script will give you error and won't write anything to the file.
If you have installed the mIRC and it's not portable and you're using Windows Vista/7 it will save the files to "C:\Users\YourUsername\AppData\Roaming\mIRC\". To make sure you can do:
To learn more about it, use the mIRC's help file. and if you couldn't understand anything, ask here and I'll help you