This post has been marked by the post author as the answer.
Quote: "Hi, i have a question: why doesn't this code write to a file?"
1- Do you means you are getting a blank file?
2- You are not getting the file?
If so, look for "textfile.txt" file, in the "files" folder.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4