How to export table data into to a text (.txt) file

Hello, I need to create a text file from a script. How to export table data into to a text (.txt) file?

Using Toad Automation this is easy.
Select to file should do the Job. There are various options as Excel, CSV, HTML etc.
Sincerely,
Shimon