Separate continuity implies measurability

Suppose $f$(x,y) is a function on $\mathbb{R}^{2}$ that is separately continuous: for each fixed variable, $f$ is continuous in the other variable. Prove that $f$ is measurable on $\mathbb{R}^{2}$.

There is also a hint: Approximate $f$ in the variable $x$ by piecewise-linear functions $f_n$ so that $f_n$ $\rightarrow$ $f$ pointwise.

I don't get how to prove the problem via this hint, or is there any other approach?

-
It is actually sufficient that the function is continuous in one coordinate and measurable in the other. Such functions are known as Caratheodory functions. – Michael Greinecker Dec 28 '12 at 17:36

Hint: take $f_{m,n}(x,y):=f\left(\frac{\lfloor mx\rfloor}n,\frac{\lfloor ny\rfloor}n\right)$, where $\lfloor t\rfloor$ is the greatest integer lower than $t$. As $f_{m,n}$ takes only countably many values, it's measurable.
why does $f_{m,n}$ converges to $f$, and how is continuity used here? – Alex Dec 28 '12 at 17:45
For a fixed $m$, $f_{m,n}(x,y)$ converges to $f\left(\frac{\lfloor mx\rfloor}m,y\right)$ as the map $t\mapsto f\left(\frac{\lfloor mx\rfloor}m,t\right)$ is continuous. Do the same taking the limit with respect to $m$. – Davide Giraudo Dec 28 '12 at 17:47