I've used something similar to that before, but it was in a different part of code (for a quick-start type of mod). I don't think the "game" variable is initialized until you actually start (or load) a new game, and in order to add entities and recipes, you have to do so in the data, data-updates, and data-final-fixes, which is initialized from the very beginning loading of the game. I think this is the only time data.raw (the thing that holds all this recipe information) is available for editing by mods.
What I did was check for one of bob's internal variables that he sets in the mod itself, which is pretty much the only way to check during the pre-initialization step, or so I would think (since that's how bob checks for his own mods' existence)