A basic question about the convergence a sequence of measurable functions Let $(X,\mathcal{B},\mu)$ be probability  space i.e. $\mu(X)=1$. If $\{g_n\}_{n=1}^{\infty}$ is a sequence of measurable functions such that $\Sigma_n \int g_n^2 d\mu <\infty$ then $g_n \to 0$ $\mu$-almost everywhere.

Attempt: Suppose $g_n\nrightarrow 0$ $\mu$-almost everwhere. Then $\mu(A)>0$ where $A:=\{x\in X: \lim g_n(x)\neq 0\}$. Since $A\subseteq B$ (here I use the fact that $\lim g_n^2=\lim g_n\lim g_n $), we have $\mu(B)>0$ where $B:=\{x\in X: \lim g_n^2(x)> 0 \}$. So $0<\int_B\lim g_n^2 d\mu=lim\int_B g_n^2d\mu$ by the monotone convergence theorem. So $\Sigma_n\int_Bg_n^2d\mu=\infty$, contradiction.
Can anyone check my attempt? And I am not sure the convergence in the question whether it is convergence in measure or not. Thanks!

By Tonelli theorem, $\sum\limits_n\int g_n^2\,\mathrm d\mu=\int h\,\mathrm d\mu$ where $h=\sum\limits_ng_n^2$. Assume that the series (of numbers) on the LHS converges. Then $h$ is integrable. Every integrable function is finite almost everywhere hence $h$ is finite almost everywhere. Finally, at each point $x$ such that $h(x)$ is finite, one can be sure that $g_n(x)\to0$ when $n\to\infty$ since the general term of every (numerical) converging series converges to $0$. $\quad\Box$
