static void Main(string[] args) { var meds = new List <bool>(); Patient patient; List <Record> records; for (int m = 1; m <= 5; m++) { records = new List <Record>(); meds.Add(MED_IMMUNITY); patient = new Patient ( CELLS, VIRUSES, REPRODUCE_PROBABILITY, CLEARANCE_PROBABILITY, meds, MUTATION_PROBABILITY ); patient.AddMeds(); int stopedAfter = 0; for (int i = 1; i <= 150; i++) { if (patient.HealthyCells == 0) { break; } stopedAfter++; patient.PatientUpdate(); records.Add(new Record { HealthyCells = patient.HealthyCells, InfectedCells = patient.InfectedCells, NumOfViruses = patient.VirusPop.Count }); } Console.WriteLine($"\n\tAfter {stopedAfter} simulations WITH {m} meds:\n"); Console.WriteLine(patient); var path = $"../../records/sim2_3_{m}.csv"; using (var writer = new StreamWriter(path)) using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) { csv.WriteRecords(records); } } }