GNU sed and BSD sed have a different command-line syntax for in-place
editing, and the current form of the script would only work with BSD
sed. The easiest way to get cross-platform behavior is to specify a
backup suffix and then just delete the backup file at the end. (BSD sed
is the default on macOS, but it's possible to acquire GNU coreutils and
have your sed be GNU sed even on macOS; I'm aware it's not officially
supported in any capacity, but it's easy enough to support here.)
An alternative would be using perl -p -i -e instead of sed -i, but I
figured it was best to make the minimal working change.