Here's a script I wrote awhile ago, that does some prepending that might be useful to you later. It allows you to add text to a file with a newline after each entry. Ignore the dialog part of it, since it really doesn't have too much to do with it.
Code:
#!/bin/sh
DIALOGRC new
dialog --clear
while : [ $menuitem =! 10]
do
dialog --title "ListMuze v0.1.01" --menu "Choose Option" 10 40 4 1 "Add Music" 2 "View List" 3 "Edit List" 10 "Quit" 2>m
enuitem.$$
menuitem=`cat menuitem.$$`
n="\n"
case $menuitem in
1) dialog --inputbox "Title/Artist" 8 100 2>music.$$ && fmt -w 100 music.$$ >> musiclist;;
2) dialog --textbox musiclist 25 100;;
3) vi musiclist;;
10) `rm -f *.$$`
exit;;
255) echo "exit esc";;
esac
done