Updated `sed` to write to a new file and then `mv`