I made a white bread recipe with whole spelt flour, probably didn't knead it enough, etc. and it didn't rise much. So it was undercooked inside and very cooked outside. I stuck a meat thermometer in the bread and it was 160-165+ degrees. Does the temperature mean it was food safe while at the same time being undercooked/heavy in the middle? (Because I kept tasting it in the vain hope it was getting edible as I cooked it again and again). What I am trying to understand is can something be undercooked tasting and in consistency but be food safe due to temperature? Thanks!
First off, there's not a lot in the ingredients you list that is likely to pose a hazard anyway. (It is possible for flour to be contaminated with bacteria, and if the bacterial count is high enough, it could pose a risk in raw dough.)
However, pasteurization to safe levels at 160F doesn't take more than a few seconds in most foods, and it's likely the interior of your loaf was above 130F (where bacteria will gradually start dying off) for quite some time.
I'd definitely consider it safe to eat right after baking, though it may not be particularly pleasant. However, underdone bread sometimes is prone to earlier spoilage, since it generally has a higher moisture content that might promote some mold, bacterial, and yeast growth after baking. The chances of it becoming actually hazardous without noticeably spoiling are probably rather low, but it's possible, particularly if the moisture content is high enough. It's much more likely that the bread would just spoil normally through the appearance of surface molds, etc., though. If you wanted to be extra cautious, you could store leftover bread in the freezer or fridge.