public void Append(List<Checkin> checkins, string exclusiveKey) { if (checkins.Count == 0) { //Console.WriteLine("No checkin records found."); return; } using (StreamWriter w = File.AppendText(this.FilePath)) { foreach(Checkin checkin in checkins) { LogRecord logRecord = new LogRecord(checkin); bool add = true; string value = string.Empty; if (!string.IsNullOrEmpty(exclusiveKey)) { value = logRecord.GetValue(exclusiveKey); add = !this.HasRecord(exclusiveKey, value); } if (!add) { //Console.WriteLine("Record with key {0} and value {1} already exists.", exclusiveKey, value); continue; } this.logRecords.Add(logRecord); Console.WriteLine("LogRecord added:"); Console.WriteLine(logRecord.ToString()); w.WriteLine(logRecord.ToString()); } // Close the writer and underlying file. w.Close(); } }