The writeini command should only be used with ini files.
if $2 isn't specified, then nothing will be written
if $2 is specified, then it should write to the file with the same name as is in $2
It would then write a section called server
and an item called nickname (followed by the contents of $3)
It's usually best to specify a specific filename when using /write or /writeini
As to your code, as long as $2 and $3 are both supplied, then it does work.