The sed command with the a (append) flag can be used to append lines to a file or variable. For example, let's say you have a file or variable with the following text.
The following command will add "New Text" to the file or variable. The a flag in this command is used to append.
sed -i '/Hello World/a New Text' $foo
In this example, the file or variable will have the following output.
Hello World New Text