The sample in this reply works fine for me.
But you need to change the filename to include the directory you want (or just use
"UiPath"+DateTime.Now.ToString("ddMMyyyyhhmmss")+".txt"
to create in the .xaml’s location).Then every time you run the workflow, a different filename will be used (depending on the timestamp).