So I have to replace words in a given file. The problem is you may have this subtext in some other word which shouldn't be replaced, so string.replace() can't be used here. The word also may have symbols like ".,;:!?"
For example in the given file there is Bobtail has a tail. and all words "tail" must be replaced with "head", so the answer in this situation shall be Bobtail has a head.