Error with newrecord/oldrecord and On Delete On Success deluge.

Error with newrecord/oldrecord and On Delete On Success deluge.

I have a report that is an executive summary of the maintenance we perform on our vehicles. It shows the last completed record of several types of services.  I have the code below in the on success of create and edit and it works as intended.  I also want it in the on success of Delete and it works fine until all records are deleted and I get hit with the error message in the attached screenshot.  Can anyone provide a answer on how to avoid that error?

for each  oldRecord in Maintenance_History_Form[Unit_Number = input.Unit_Number && Service_Performed = input.Service_Performed && Newest_Record = true]
{
    oldRecord.Newest_Record=false;
}
//fetch the latest record
newRecord = Maintenance_History_Form[Unit_Number = input.Unit_Number && Service_Performed = input.Service_Performed] sort by Service_Date desc;
newRecord.Newest_Record=true;