How do I open a file for reading and writing ? I want first open a file for reading a word and then for writing to replace the read word with some other word.

Thanks