You cannot use client-side scripting (javascript) to write to a server-side file. For that you need server-side scripting, such as PHP, Perl, ASP, Ruby, etc, etc. It would be pretty dangerous if javascript could do things like this, since javascript can be modified at the client (browser) end. So that would allow you to take control of someone's webserver, if what you are suggesting were possible.
Sorry!