Javascript runs on the client's browser and cannot access the server or write to a text file on it. You need a server side language such as PHP/ASP to accomplish this.
I'm going to move this topic to "Script requests".
And here's a similar request which might help:
http://www.programmingtalk.com/showthread.php?t=36187