Then why serve it to the kid only to take it away a few minutes later?
Flawed process.
The correct process is that the children’s account should be debited before they walk away with the food. If they don’t have enough of a positive balance then at least some of the food can probably be returned for distro to another child rather than being tossed.
An even better process would be to check the account balance BEFORE the food is even distributed. This may not work in situations where price is determined by weight (salad bars, assuming the school has such a thing), but it would still be a good mitigation step.