Question: Can anybody give some sample code to read and write a file using JavaScript?

Answer: 
The future is here! The proposals are closer to completion, no more ActiveX or flash or java. Now we can use:

* [File System APIs](https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API)
* [Native Drag&Drop File Access](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API)

You could use the Drag/Drop to get the file into the browser, or a simple upload control. Once the user has selected a file, you can read it w/ Javascript: <http://www.html5rocks.com/en/tutorials/file/dndfiles/>
If you are using JScript (Microsoft's Javascript) to do local scripting using WSH (NOT in a browser!) you can use `Scripting.FileSystemObject` to access the file system.

I think you can access that same object in IE if you turn a lot of security settings off, but that would be a very, very bad idea.

[MSDN here](http://msdn.microsoft.com/en-us/library/6kxy1a51(VS.85).aspx)