Use sed instead

This needs the extra newline character defined in a variable because
shells treat the ${} expansion differently for replacing newline characters.