I'm not very Groovy expert, but recall answering something similar at JMeter soap response - data analysis
using Beanshell.
I guess that if you change your code line
File file = new File("logs/output/scenario_times_idtv.txt").newOutputStream().withWriter { out ->
out.append(cm + ";" + scenario_start + ";" + scenario_end);
to something like:
FileOutputStream file = new FileOutputStream("logs/output/scenario_times_idtv.txt", true);
file.append((cm + ";" + scenario_start + ";" + scenario_end).getBytes());
file.flush();
file.close();
your script will behave as expected. Mind the true
parameter of FileOutputStream. It tells the stream to append existing file. Perhaps there is a Groovy analogue, but this bit should work as well.