public void writeToCSVFile() { this.fileCreated = true; //add disconnected players tp log int firstRows = 5 + getNumOfPlayers(); var toFile = writeToFile; if (toFile != null) { if (!Program.LogAgents) { firstRows = 5 + numOfHumanPlayers; } toFile.Insert(firstRows, "disconnected player id, round"); int j = firstRows + 1; for (int i = 0; i < this.playersDisconnected.Count; i++) { toFile.Insert(j, this.playersDisconnected[i]); j++; } for (int i = 0; i < toFile.Count; i++) { file.write(toFile[i]); } } file.Close(); }