Implement basic textual find/replace in files

Also fixed a bug and dealt with some nonobvious asynchrony in one of the existing tests.