[guided]The purpose of this step is to replace the adapted frame $(s_1,\dots,s_k)$ by an adapted orthonormal frame. The point requiring verification is smoothness: Gram-Schmidt is performed separately in each fibre, so we must check that the resulting fibrewise formulas vary smoothly with the base point $p\in U$.
We define smooth sections $u_j:U\to E|_U$ and $e_j:U\to E|_U$ recursively. First set $u_1:=s_1$. Since $s_1(p)$ is part of a basis of $E_p$ for every $p\in U$, it is nowhere zero. Because $g_p$ is positive definite on $E_p$, the function $h_1:U\to \mathbb{R}$ defined by $h_1(p):=g_p(u_1(p),u_1(p))$ is smooth and satisfies $h_1(p)>0$ for every $p\in U$. Hence $\sqrt{h_1}$ is a positive smooth function, and we may define
\begin{align*}
e_1(p):=\frac{u_1(p)}{\sqrt{h_1(p)}}.
\end{align*}
Then $e_1$ is smooth, $g_p(e_1(p),e_1(p))=1$, and $e_1(p)$ spans the same one-dimensional subspace as $s_1(p)$.
Now suppose $e_1,\dots,e_{j-1}$ have been constructed as smooth sections and form, in each fibre $E_p$, an orthonormal basis of $\operatorname{span}\{s_1(p),\dots,s_{j-1}(p)\}$. Define
\begin{align*}
u_j(p):=s_j(p)-\sum_{\ell=1}^{j-1}g_p(s_j(p),e_\ell(p))e_\ell(p).
\end{align*}
This is the Gram-Schmidt subtraction step: from $s_j(p)$ we subtract its components in the already constructed orthonormal directions. Each coefficient $a_{j\ell}:U\to \mathbb{R}$ defined by $a_{j\ell}(p):=g_p(s_j(p),e_\ell(p))$ is smooth because $g$ and the sections $s_j,e_\ell$ are smooth. Therefore $u_j$ is a smooth section.
We next check that the denominator used to normalize $u_j$ is never zero. If $u_j(p)=0$, then
\begin{align*}
s_j(p)=\sum_{\ell=1}^{j-1}g_p(s_j(p),e_\ell(p))e_\ell(p),
\end{align*}
so $s_j(p)$ lies in $\operatorname{span}\{e_1(p),\dots,e_{j-1}(p)\}$. By the induction hypothesis, this equals $\operatorname{span}\{s_1(p),\dots,s_{j-1}(p)\}$, contradicting the [linear independence](/page/Linear%20Independence) of $(s_1(p),\dots,s_j(p))$. Thus $u_j(p)\ne 0$ for every $p\in U$. The function $h_j:U\to \mathbb{R}$ defined by $h_j(p):=g_p(u_j(p),u_j(p))$ is therefore positive and smooth, so
\begin{align*}
e_j(p):=\frac{u_j(p)}{\sqrt{h_j(p)}}
\end{align*}
defines a smooth section.
Finally, fix $\ell<j$. By the orthonormality of $e_1(p),\dots,e_{j-1}(p)$, the sum
\begin{align*}
\sum_{m=1}^{j-1}g_p(s_j(p),e_m(p))g_p(e_m(p),e_\ell(p))
\end{align*}
has only one nonzero term, namely the term $m=\ell$, and therefore equals $g_p(s_j(p),e_\ell(p))$. Hence $g_p(u_j(p),e_\ell(p))=0$. After normalization, $g_p(e_j(p),e_\ell(p))=0$ for $\ell<j$ and $g_p(e_j(p),e_j(p))=1$. Thus the induction produces a smooth orthonormal frame $(e_1,\dots,e_k)$ of $E|_U$. Since the first $r$ Gram-Schmidt vectors are constructed only from $s_1,\dots,s_r$, the list $(e_1(p),\dots,e_r(p))$ spans the same subspace as $(s_1(p),\dots,s_r(p))$, namely $F_p$.[/guided]