He had said he would cook dinner, but first he needed to what?
buy food buy groceries hungry
buy groceries
if he is cooking then he wouldn't need to buy food (food most likely refers to already prepared food in this case).  he would need to buy groceries prior to cooking dinner.
cook dinner,but first