Forum OpenACS Development: Re: writing a TCL string to a file
template::util::write_fileproc is basically just using
putsto write your string to a file. So you need to have actual linefeeds in the string you pass to it, not the literal string "\n". Either make sure your "\n" is interpreted at the time you set your string, or if necessary (unlikely), call subst on the string later on, just before you pass it to template::util::write_file.
Also, my advice is when you have a chance, review Tcl's rules for parsing and evaluation, as this sort of problem indcates you haven't become completely familiar with them yet.