I am printing the responses in a csv file using beanshell sampler but it is not stopping after completion.

What can be done so that it stops after printing it. Below is the sample code I have used acctId is used in the pre processor from other thread group.

```
import java.io.FileWriter;
import java.util.Arrays;
import java.io.Writer;
import java.util.List;

char SEPARATOR = ',';

public void writeLine(FileWriter writer, String[] params, char separator)

{
   boolean firstParam = true;

   StringBuilder stringBuilder = new StringBuilder();

   String param = "";
   for (int i = 0; i <params.length; i++)

   {

      param = params[i];

      log.info(param);

       if (!firstParam)

       {
               stringBuilder.append(separator);

       }

       stringBuilder.append(param);

       firstParam = false;

   }

   stringBuilder.append("\n");

   log.info(stringBuilder.toString());

   writer.append(stringBuilder.toString());

}

String csvFile = "D:/jmeter/test1/result.csv"; // for example '/User/Downloads/blabla.csv'

//String[] params = {"${acctId}", "${tranId}"};
String[] params = {"${acctId}"};

FileWriter fileWriter = new FileWriter(csvFile, true);

writeLine(fileWriter, params, SEPARATOR);

fileWriter.flush();

fileWriter.close();

```