Bad luck! Once when I had the same problem & complained to the dietetica, I was directed, with not a trace of irony, to look at this: http://medicinalternativa.blogspot.com.ar/2006/01/para-que-sirve-la-terapia-de-gorgojos.html and treat the bugs as a bonus.
I wouldn't go that far, but have accepted that bugs do live in my food, to the point where I wonder what the hell treatment food gets in other places to eliminate them.
A lot of grains and even pasta come pre-loaded with extra protein, usually it's not actually walking around yet though!
The best way to stop things from hatching and eating your food is to cook and eat it as soon as possible after purchase.
Failing that, deny them the warmth and air they need, using vacuum storage bags/tubs and/or keeping everything in the fridge.
A stint in the freezer is good but not infallible for killing moth.