Getting Java Script Error:: delete terminated - could not access row id(display,process.option)

Hello Experts,

My intention is to delete Eventout data on weekly basis. I have written the following JS to achieve the same. It's working fine while records are there. But, while no records are found, then it is throwing error as delete terminated - could not access row id(display,process.option). 

Please let me know how to overcome so that if no records found, it will print as "No Records Found" instead of throwing error.


function PurgeEventout()
var fpurge = new SCFile("eventout");
var rc;
var time = new Date();
var timecalc = 4560*80000;
var tempbefore = new Date(time.getTime() - timecalc);

var type = "page"
//var type = "email/page/pmc"
//var qry = "evtype=\"" type "\" and evsysseq=\"0000000100296836\""

var qry = "evtype=\"" type "\""
// "\" and evexpire<\"" tempbefore "\""

rc = fpurge.doSelect( qry );

if ( tempbefore > fpurge.evexpire)

}while(fpurge.getNext() == RC_SUCCESS)

print("script complete")