Write to file in Ruby. From http://stackoverflow.com/questions/2777802/how-to-write-to-file-in-ruby