I'm trying to learn python 3. I was going through the exercises of File Handling. I'm having an issue with my code, when i try to write a file, it doesn't make any file sometimes and sometimes a file is generated but when i try to read it. It shows blank output. Most of time it give some sort of syntax error, while i'm using the basics and simple code. But sometime instead of using run in terminal, when i click on run code, it produces the output but still gives error on terminal.
I've tried doing it with, With and casual method. I've looked up on google for the issue but i didn't got any specific answer. I've tried to follow the python documentation and their code.
I've tried both open with method and casual method but i'm still facing this issue.
```
with open('text.txt','w+')as f:
f.write("Hell Men")
with open('text.txt','r+')as f:
print(f.read())
```
Also tried it this way:
file=open('word.txt','w')
file.write("Python you are making me mad")
file.read()
I was expecting the content of the file in output, but instead it shows blank on clicking run code.
Error: invalid syntax