Why is $\mathfrak{g}(A)=\mathfrak{g}'(A)$ iff $\det(A)\neq 0$?

In many sources (Victor Kac, Zhexian Wan, etc.), it's stated as a remark that if $\mathfrak{g}(A)$ is the Kac-Moody algebra of a generalized Cartan matrix $A$, then $\mathfrak{g}(A)=\mathfrak{g}'(A)$, the derived subalgebra, iff $\det(A)\neq 0$, but none has proof.

Is there a proof of this remark anywhere?

$$\def\g{\mathfrak{g}} \def\h{\mathfrak{h}}$$
Let $\{e_{i}, f_{i}\}_{i=1}^{n}$ be the standard generators of the Kac Moody algebra $\g$ and let $\alpha_{1}^{\vee}, \ldots, \alpha_{n}^{\vee}$ be the simple coroots in its Cartan subalgebra $\h$. Then, by the defining relations of the Kac Moody algebra, the derived subalgebra $\g'(A)$ is the Lie subalgebra generated by $e_{i}, f_{i}, \alpha_{i}^{\vee}.$
On the other hand $\g$ is generated by $\h$ and $\{e_{i}, f_{i}\}$.
If $A$ is nondegenerate, then the rank of $\g$ is $n$ and hence the dimension of $\h$ is $n$, which means that it is spanned by the $\alpha_{i}^{\vee}$. Hence, $\g = \g'$.
Conversely, you can check that $\g' \cap \h$ is spanned by the $\alpha_{i}^{\vee}$ and is hence of dimension $n$. If $A$ is degenerate, then the rank of $\g$ is less than $n$ and hence $\h$ has dimension $2n - r > n$. Thus, $\g' \cap \h \not= \h$ in this case and hence $\g' \not = \g.$