Use $ for sed.

Formatting the script file is not a good idea!