// Initiate record search with input id public static void SearchRecords(string patientID) { var i = 0; foreach (var item in RecordsList) { Console.WriteLine("Searching Records"); Console.WriteLine(); if (item.patientID == patientID) { //how many iterations are done when a match is found //Console.WriteLine("Match"); //Console.WriteLine("{0} many iterations", i); Patient.WritePatientFile(RecordsList, i); Console.WriteLine(); //perform delete request DeleteFile(RecordsList, i); //minus 1 from counter so smaller than list length for next step i--; break; } i++; } int len = RecordsList.Count; if (i == len) { Console.WriteLine("Patient ID does not exist"); } }