title: Scala: Print separators when using output stream
body: <p>When we need an array of strings to be concatenated, we can use mkString method:</p>
  
  <pre><code>val concatenatedString = listOfString.mkString
  </code></pre>
  
  <p>However, when we have a very long list of string, getting concatenated string may not be a good choice. In this case, It would be more appropriated to print out to an output <strong>stream</strong> directly, Writing it to output stream is simple:</p>
  
  <pre><code>listOfString.foreach(outstream.write _)
  </code></pre>
  
  <p>However, I don't know a neat way to append separators. One thing I tried is looping with an index:</p>
  
  <pre><code>var i = 0
  for(str &lt;- listOfString) {
    if(i != 0) outstream.write ", "
    outstream.write str
    i += 1
  }
  </code></pre>
  
  <p>This works, but it is too wordy. Although I can make a function encapsules the code above, I want to know whether Scala API already has a function do the same thing or not.</p>
  
  <p>Thank you.</p>