title: Spark - Delimiter not found, how to add a separator in the end of the line?
body: <p>I'm getting an error when copying data into Redshift. After looking into the <code>stl_load_errors</code> table it appeared that the reason is due to <code>Delimiter not found</code>.</p>
  
  <p>I'm using a group separator between the dataframe columns and saving the data as a text file: </p>
  
  <pre><code>val columns: Array[Column] = salesDF.columns.map(col)
  val dataFrame = salesDF.select(concat_ws(String.valueOf(29.toChar), columns: _*)).write.text(outputLocation)
  </code></pre>
  
  <p>The resulting data in a file looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/PmUeu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PmUeu.png" alt="enter image description here"></a></p>
  
  <p>After comparing with data from files that load into Redshift successfully, I suspect that the problem is that there is no separator in the very end. </p>
  
  <p>But the delimiter is already passed to <code>concat_ws</code>. And I don't quite understand how to achieve this when saving data like above? In other words, how can I add the same separator to the end of every line as well?</p>