Use the `inreplace` function in preference to shelling out to sed.