title: Outputting a single csv file
body: <p>In a channel I have a Source which is a Channel Reader and which receives 13 rows of data from a SQL database.
  I have a Destination which is a File Writer which needs to create a single csv file but is creating 13 separate csv files using the following JavaScript step in the Source.
  How do I update the code or the configuration to create a single csv file?</p>
  <pre><code>const delimiter = ',';
  const newLine = '\r\n';
  var outputResultStr = new java.lang.StringBuilder();
  var outputFileName = 'CSVData_' + DateUtil.getCurrentDate('yyyyMMDDHHMMSS');
  
  outputResultStr.append('field#1Header').append(delimiter).append(
                  'field#2Header').append(delimiter).append(
                  'field#3Header').append(delimiter).append(
                  'field#4Header').append(delimiter).append(
                  'field#5Header').append(delimiter).append(
                  'field#6Header').append(delimiter).append(
                  'field#7Header').append(delimiter).append(
                  'field#8Header').append(delimiter).append(
                  'field#9Header').append(delimiter).append(
                  'field#10Header').append(newLine);
  
  for each (msg['result'] in msg) {
  outputResultStr.append(msg['field#1'].toString()).append(delimiter).append(
                      msg['field#2'].toString()).append(delimiter).append(
                      msg['field#3'].toString()).append(delimiter).append(
                      msg['field#4'].toString()).append(delimiter).append(
                      msg['field#5'].toString()).append(delimiter).append(
                      msg['field#6'].toString()).append(delimiter).append(
                      msg['field#7'].toString()).append(delimiter).append(
                      msg['field#8'].toString()).append(delimiter).append(
                      msg['field#9'].toString()).append(delimiter).append(
                      msg['field#10'].toString()).append(newLine);
  </code></pre>
  <p>}</p>
  <pre><code>msg = outputResultStr;
  channelMap.put('final_output', outputFileName);
  </code></pre>