Your first code? See me impressed.
Nevertheless your intuitive approach (while) is not a good way to go.
You have obvious states in your processing, handle them by a state machine.
I referred to the sketch output of the BME initialization after a power on, that leads to malfunction.