I looked through all over, but could not find a good simple code that allows me to prepend a string to an existing file.
The file is this:
brave
charlie
delta
echo
I want to prepend "alpha" to the file so it'll look like this:
alpha
bravo
charlie
delta
echo
What is the best way to go about this? What I have tried so far is this:
with open('file', 'rb+') as fp:
fp.seek(0)
fp.write('alpha)
but this overwrites the first line