It wont work with the file names in the /write\'s as you have them. Instead of:
write Mlogs\\ $+ %logmonth $+ \\ $+ $chan $+ . $+ $network $+ .txt [New Session start at $fulldate on $network on $chan $+ ]
it should be:
write $+(Mlogs\\,%logmonth,\\,$chan,.,$network,.txt) [New Session start at $fulldate on $network on $chan $+ ]