For heavy writing tasks it's recommended to use the new file handling commands (/help /fopen). Also, it's possible to handle errors like the one you encountered (/help error handling). Both features have been improved since they were added so it's probably best to test them on the most recent version of mIRC (6.16).