Sending line breaks in SMS over dbus-send?

I wrote myself a script to compose a message on my computer, then send it to the SMS app on my phone (also good for just sending arbitrary strings to the phone).

It does NOT send messages, just transfers the text.

Anyhow, I had similar problems at first and ended up with this, which works reliably:

#!/bin/bash

host=xa2 # defined in ~/.ssh/config

sep="=================="
printf "Enter message text\n$sep\n"
# Read stdin & escape it https://stackoverflow.com/a/20053121
text="$(LC_ALL=C sed -e 's/[^a-zA-Z0-9,._+@%/-]/\\&/g; 1{$s/^$/""/}; 1!s/^/"/; $!s/$/"/' /dev/stdin)"
exec ssh $host DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/100000/dbus/user_bus_socket dbus-send --type=method_call --dest=org.nemomobile.qmlmessages / org.nemomobile.qmlmessages.startSMS array:string:\"\" string:$text