I've recently seen a proof of the dominated convergence theorem that states that WLOG we can assume that an integrable function is finite everywhere. I know that an integrable function must be finite $\mu$-almost everywhere and that if $f,g: \Omega \to \overline{\mathbb{R}}$ are measurable and equal $\mu$-almost everywhere, then their integrals on a measurable set $E$ are equal. So I am trying to prove that we can simply change a function $f$ at points $x: f(x)= \pm \infty$ and obtain a measurable function $g$ that is finite everywhere.
More precisely:
Let $(\Omega, \Sigma, \mu)$ be a measure space and let $f: \Omega \to \overline{\mathbb{R}}$ be measurable where we use the Borel $\sigma$-Algebra for $\overline{\mathbb{R}}$, i.e.
$\mathcal{B}(\overline{\mathbb{R}}) = \{B \cup A : B \in \mathcal{B}(\mathbb{R}), A \subset \{-\infty,\infty\}\}$. Note that $\mathcal{B}(\overline{\mathbb{R}})$ is generated by the set $\{(a,\infty]: a \in \mathbb{R}\}$.
Now define a function $g: \Omega \to \overline{\mathbb{R}}$ as follow:
Let $g(x)=f(x)$ for $x$ with $f(x) \in \mathbb{R}$ and $g(x)=0$ for $x$ with $f(x)=\pm \infty$.
Now is $g$ measurable?
My idea is to look at the set $(a, \infty]$ for $x \in \mathbb{R}$ and show that its inverse image
$g^{-1}((a, \infty]) = \{x \in \Omega: g(x)>a\}$
is measurable.
First assume that $a<0$, then
$\{x \in \Omega: g(x)>a\} = \{x \in \Omega: a<g(x)<0\} \cup \{x \in \Omega: g(x)=0\} \cup \{x \in \Omega: 0<g(x)<\infty\} \cup \{x \in \Omega: g(x)= \infty\}$
Also
$\{x \in \Omega: a<g(x)<0\}=\{x \in \Omega: a<f(x)<0\}$,
$\{x \in \Omega: 0<g(x)<\infty\}=\{x \in \Omega: 0<f(x)<\infty\}$,
$\{x \in \Omega: g(x)=0\} = \{x \in \Omega: f(x)=0\} \cup \{x \in \Omega: f(x)=\pm \infty\}$ and
$\{x \in \Omega: g(x)= \infty\} = \emptyset$.
A similar argument holds for $a \geq 0$.
Since $f$ is measurable, all these sets are measurable, and hence $g$ is also measurable.
Is this fine or did I make a mistake?