The forward price $K$, determined at time $t$, is the amount such that the payoff at time $T$ is $S_T-K$, while the value at time $t$ is zero. That is,
\begin{align*}
B_t E\left(\frac{S_T-K}{B_T}\mid \mathcal{F}_t \right)= 0,
\end{align*}
Where $E$ is the risk-neutral expectation operator. Then,
\begin{align*}
K&=\frac{E\left(\frac{S_T}{B_T}\mid \mathcal{F}_t \right)}{E\left(\frac{1}{B_T}\mid \mathcal{F}_t \right)}\\
&=\frac{E\left(\frac{S_T}{B_T}\mid \mathcal{F}_t \right)}{\frac{1}{B_t}E\left(\frac{B_t}{B_T}\mid \mathcal{F}_t \right)}\\
&=\frac {\frac{ S_t}{ B_t} }{\frac{1}{B_t}P (t,T)}\\
&=\frac{S_t}{P(t,T)},
\end{align*}
where
\begin{align*}
P (t,T) &= E\left(\frac{B_t}{ B_T}\mid \mathcal {F}_t \right)\\
&=E\left(e^{-\int_t^T r_s ds}\mid \mathcal {F}_t \right)
\end{align*}
is the price at time $t$ of a zero-coupon bond with maturity $T$ and unit face value.
Alternatively, at time $t$,
enter into a forward contract with forward price $K$, which has zero cost at time $t$,
short one share with income $S_t$, and
long $\frac{S_t}{P (t,T)}$ units of zero-coupon bond with maturity $T$.
The net cost at time $t$ is zero. At maturity $T$,
the forward contract has value $S_T-K$,
the short position of one share has value $-S_T$, and
the zero-coupon bond has value $\frac{S_t}{P (t,T)}$.
Assuming arbitrage free, the value at time $T$ is then
\begin{align*}
S_T-K - S_T + \frac{S_t}{P (t,T)} = \frac{S_t}{P (t,T)}-K =0,
\end{align*}
that is,
\begin{align*}
K=\frac{S_t}{P (t,T)}.
\end{align*}