Not at all sure if this is possible. Javascript can't create files on the client machine - security issue. Maybe you could do this with some kind of server-side language like
PHP or
ASP and then let the user download the file. If I were you I would consider writing a program that does this and not try to do it out of the browser.