Echo output to file fails

Yes you are right, the first is bash, the second is Python. I took a line of bash in Python. I am an idiot. so I have to open a file write to it and close it.

Thank you
Happy New Year