You cannot insert content at the beginning of a file. The only thing you can do is either replace existing content or append bytes after the current end of file.
Any solution to your question then requires a temporary file (or buffer) to be created (on memory or on disk) which will eventually overwrite the original file.
Beware of not loosinglosing data by preserving the original file while buildingcreating the new one, should the file system happen to be full during the process. eg:
cat <(echo task go there) todo.txt > todo.txt.new && mv todo.txt.new todo.txt