Nice article, good to hear ed is not dead. =)
You could also just add the text after the matching line. A little simpler and more straight forward.
$ cat > /tmp/ed-script
/baz
a
- elephants
.
w
q
$ cat /tmp/2
foo:
- bar
- baz
- bananas
$ cat /tmp/ed-script | ed /tmp/2
33
- baz
47
$ cat /tmp/2
foo:
- bar
- baz
- elephants
- bananas
$·