Don't you want to save at least one of these invalid waypoints since you're using that to determine when to stop loading.

I think you could just move this if after the ObjSave() call and it would be more correct.