I tested your code and it seems to work. As an alternative you can use this:
with open('test1.txt', 'w', encoding='utf-8') as f:
f.write("123 True blah")
Since I had Python 2 as default, I needed to execute it via:
python3 myfile.py
The 3 means it is for Python 3 and not 2. Maybe that's where you're not getting it to work?
Here is also another way to do it with the print function:
print("123, True, 'blah'", file=open('test1.txt', 'a'))
The 'a' at the end stands for append.
Ref:
Directing print output to a .txt file in Python 3
Since the program seems to work (at least for me) and the fact I do not have PyCharm. I can only offer you the documentation for 3.5 print(). Maybe something here can help you out:
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
"""
Print objects to the text stream file, separated by sep and followed by end. sep, end, file and flush, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.
The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Since printed arguments are converted to text strings, print() cannot be used with binary mode file objects. For these, use file.write(...) instead.
Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.
"""