fix to an infinite loop when the same word is in --search and --replace