beneficial bacteria are tolerant of acidic environments (yogurt/pickles/kimchi), and while a bulk of them die in the stomach some do get through. we know this because eating probiotic rich foods regularly does result in a measurable difference in the populations of those specific bacteria in the gut (as long as you continue consuming them).