Creating and writing to a file

Depends what you're writing and to where. To create and write to a
simple text file is easy:

File.open('filename','w') { |f|
   f.puts 'text to write to file'
}