Edit does one thing: find old_string in a file and replace it with new_string, touching nothing outside that match.
The catch is that old_string must appear exactly once in the file. If it appears times, the edit fails with an error. If it appears or more times, it also fails. This forces you to provide enough surrounding context to make the match unique. I find this design sensible: an ambiguous match on a common string like return null could corrupt logic in the wrong function. Edit is the right tool whenever you're changing an existing file. Write is for creating from scratch.