Linux :
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
or
sed -i '1s/^/task goes here\n/' todo.txt
or
sed -i '1itask goes here' todo.txt
Mac os x :
sed -i '.bak' '1s/^/task goes here\'$'\n/g' todo.txt
or
echo -e "task goes here\n$(cat todo.txt)" > todo.txt
or
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt