title: Add each array element to the lines of a file in ruby
body: <p>If I have an array of strings e.g.</p>
  
  <pre><code>a = ['a', 'b', 'c', 'd']
  </code></pre>
  
  <p>and I want to output the elements, to a file (e.g. .txt) one per line. So far I have:</p>
  
  <pre><code>File.new("test.txt", "w+")
  File.open("test.txt", "w+") do |i|
      i.write(a)
  end
  </code></pre>
  
  <p>This gives me the array on one line of the test.txt file.
  How can I iterate over the array, adding each value to a new line of the file?</p>