implemented replaceWord()

Wrote implementation for replaceWord(). Everything is still completely
untested.