...and the reason for that verse is given in the next few verses.
It is not a command to not eat any food sacrificed to idols; it is a command not to do so in the presence of a brother who brings up the subject, because the weaker brother has a weak conscience about the matter. The weaker brother would be tempted to sin if he ate the meat, and therefore, the stronger brother, out of love, even though his conscience does not prick him, abstains from eating the meat.
That is why Paul says “Eat anything that is sold in the marketplace without questions of conscience, 10:26 for the earth and its abundance are the Lords. “