Charles L. Snyder wrote: > Thanks to everyone for their suggestions! > This code does absolutely everything I need, except the resulting > text file has no line breaks. How do force a line break for each of > the elements in the array being sent to the output text file ? > > require 'ostruct' > require "rexml/document" > include REXML > print "What is the name of the xml file?" > p myFile = gets.chomp > doc = Document.new File.new("#{myFile}"+'.xml') Btw, you are not closing the file here. And you just need a single string interpolation. You can do doc = File.open("#{myFile}.xml") {|io| Document.new io} > quiz=[] > > doc.elements.each("QUIZ/QUESTION") do |el_q| > question = OpenStruct.new > quiz.push question.text = el_q.attributes["TEXT"] > question.answer = el_q.attributes["EXPLAIN"] > i=0 > # ... > el_q.elements.each("CHOICE") do |el_ch| > (question.choices||=[]) << el_ch.text > quiz.push "False! "+ ("#{question.answer}") Suggestion: quiz.push "False! #{question.answer}" > quiz.push("#{question.choices[i]}") Another one: quiz.push(question.choices[i].to_s) > i+=1 > end > end > File::open("#{myFile}" + '.quiz', 'w') do |f| > f << quiz Insert linebreaks: f.puts quiz > end > Kind regards robert