Let ${Y_{n}, n \geq 0}$ be real-valued random variables on $(\Omega, \mathcal{F}, P)$ that satisfy $\lim _{x \rightarrow \infty} X_{n}(\omega) = \infty$ for every $\omega \in \Omega$, and let $B < \infty$ be a real number. Prove that the integer-valued quantity $$τ (ω) := \inf\left\{n ≥ 0 : X_{n}(\omega)\geq B\right\}$$ is a random variable. Also, prove that $X_{\tau}$ is a random variable.
My attempt so far,
I have been able to prove that $\tau(\omega)$ is a random variable. If some $k \notin \mathbb{Z^{+}}$, then $\tau^{-1}(\{k\}) = \phi$. We know that $\phi$ has a pre-image in $\mathcal{F}$.$$\tau_{\omega} = k \implies X_{k}(\omega) \geq B \cap X_{i}(\omega) < B$$ for all $i<k$. Since, the $\{X\}'s$ are random variables, $A_{k} \cap (\cap_{i=1}^{k-1}A_{i})$ where, $A_{k} = X_{k}^{-1}([B,\infty)) , X_{k}^{-1} = ((-\infty,B)).$
I am not so sure about how to proceed for proving that $X_{\tau}$ is a random variable.
Any help would be appreciated.
Hint: Write $$X_{\tau} = \sum_{n=0}^{\infty} X_n 1_{\{\tau=n\}}$$