# Product measure question, using point wise limit

Suppose $(X,M,\mu)$ is a measure space, and that $f$ is a real-valued function on $X\times \mathbb{R}$. Show that if the sections $f_x$ are continuous functions for every $x\in X$ and the sections $f^{y}$ are measurable functions for every $y\in\mathbb{R}$ then $f$ is measurable with respect to the product $\sigma$-algebra $M\otimes B_{\mathbb{R}}$. Hint - write $f$ as the pointwise limit of a sequence of measurable functions.

I think we have to use Fubini-Tonelli Theorem, but I am not sure, any suggestions is greatly appreciated, this one is pretty tough.

Define the sequence of functions $g_n :\mathbb R\to\mathbb R$ by $$g_n(y) = \max_{k\in\mathbb Z}\left\{\frac kn : \frac kn \leqslant y\right\}.$$ Then $\lim_{n\to\infty}g_n(y)=y$ so by continuity of $f_x$, we have $$\lim_{n\to\infty} f\left(x,g_n(y)\right) = f(x,y)$$ for each $(x,y)\in X\times\mathbb R$. Letting $f_n(x,y):= f\left(x,g_n(y)\right)$, we see that $f$ is the pointwise limit of $f_n$. If $B$ is a Borel set then $$f_n^{-1}(B) = \bigcup_{k\in\mathbb Z} (f_n^k)^{-1}(B)\times \left[\frac kn, \frac{k+1}n \right],$$ so that $$f_n^{-1}(B)\in\mathcal M\otimes\mathcal B_{\mathbb R}.$$ It follows that $$f^{-1}(B) = \lim_{n\to\infty} f_n^{-1}(B)\in\mathcal M\otimes\mathcal B_{\mathbb R},$$ from which we conclude.