Prove that this function is measurable I cannot write a neat proof of this result, so I would like to see how to be precise in these kinds of arguments.. Here is the problem

Let $I=[0,1]$ and let $f\colon I\times\mathbb R\to \mathbb R$ be a function such that
i) $f(\cdot,x)$ is measurable for all $x\in\mathbb R$;
ii) $f(t,\cdot)$ is continuous for a.e. $t\in I$.
Prove that, for every continuous function $x\colon I\to\mathbb R$, the function
$$g_x(t):=f(t,x(t))$$
is measurable.

Thank you for your kindness..
 A: Fix $x\colon[0,1]\to \Bbb R$ a continuous function and define 
$$g_n(t):=f\left(t,\frac{\lfloor nx(t)\rfloor}n\right),$$
where $\lfloor\cdot\rfloor$ denotes the floor function, that is, the map which gives to a real number the largest integer which is smaller or equal than this real number. 


*

*We check that $g_n$ is measurable, using the assumption i), and writing $g_n$ as as $$\lim_{k\to +\infty}\sum_{j=-k}^kf(t,j/n)\chi_{[j,j+1)}(nx(t)).$$
Indeed, the map $t\mapsto f(t,j/n)$ is measurable by i), and so is $t\mapsto f(t,j/n)\chi_{[j,j+1)}(nx(t))$. A sum of measurable functions is measurable, and pointwise limit of measurable functions still is measurable. 

*Then using ii), show that $g_n(t)$ to $g(t)$ for almost every $t$. 

A: Here is a less slick approach:
Suppose $x= \alpha 1_A$, with $A$ measurable. Then $g_x^{-1} V = \{t \in A|f(t,\alpha) \in V\} \cup \{t \in A^C|f(t,0) \in V\}$, hence $g_x$ is measurable.
Now let x be simple, $x = \sum_k \alpha_k 1_{A_k}$, where we may take the $A_k$ to be disjoint. Then we can write $g_x(t) = f(t,0)+\sum_k (f(t,\alpha_k 1_{A_k})-f(t,0))$, the sum of measurable functions, hence $g_x$ is measurable.
Now let $x$ be measurable, and let $s_n$ be a sequence of measurable simple functions such that $s_n(t)\to x(t)$ and $|s_n(t)| \leq |x(t)|$. Then $g_x(t) = \lim_{n \to \infty} g_{s_n}(t)$, so $g_x$ is the limit of measurable functions. Hence $g_x$ is measurable.
