title: Write to CSV file in JMeter
body: <p>I am using below code to write user token to a file in Beanshell Post Proccessor.
  Below code work fine with no issues. But when we execute the script from master -&gt; 3 slaves(3 Slaves execute JMX file in parallel)</p>
  <p>Few empty lines and some truncated tokens are written to the file. Appreciate if any one help on this.
  We need to have actual tokens written to the file with out any truncations and empty lines</p>
  <pre><code>import java.io.File;
  import org.apache.jmeter.services.FileServer;
  import java.io.FileWriter;
  import java.io.PrintWriter;
  import java.util.Arrays;
  import java.io.Writer;
  
  File file = new File(&quot;/tmp/token.csv&quot;);
  FileWriter fstream = new FileWriter(file, true);
  
  BufferedWriter out = new BufferedWriter(fstream);
  
  String accesstoken = vars.get(&quot;UserTOKEN&quot;);
  out.write(accesstoken);
  out.write(&quot;\n&quot;);
  
  out.close();
  fstream.close();
  </code></pre>