title: Write bash array to file with newlines
body: <p>How do I write an array to a file such that each element is separated by a newline?</p>
  
  <p>The following does not work:</p>
  
  <pre><code>testa=( 1 2 3 )
  echo "${testa[@]}" &gt; file.txt
  </code></pre>
  
  <p>(now the elements are separated by spaces on a single line)
  I would like avoid writing a <code>for</code> loop for this...</p>