Hartshorne's proof of Halphen's theorem

Apologies if this is not quite at the level of MathOverflow, but it has already been asked at MSE and gone unresolved for several years despite a bounty.

Hartshorne states the theorem as follows:

Proposition IV.6.1. A curve $$X$$ of genus $$g\geq 2$$ has a nonspecial very ample divisor $$D$$ of degree $$d$$ if and only if $$d\geq g+3$$.

The necessity is shown, and then sufficiency. The idea is to show that the set $$S$$ of divisors $$D \in X^d$$ such that there exists $$D' \sim D$$ and points $$P,Q \in X$$ with $$E = D'-P-Q$$ an effective special divisor has dimension $$\leq g+2$$. Because $$d\geq g+3$$ this means there is some $$D\notin S$$ that is nonspecial and very ample of degree $$d$$.

Hartshorne shows that the set of divisors of the form $$E+P+Q$$ in $$X^d$$ that are nonspecial with $$E$$ a special effective divisor has dimension $$\leq g+1$$.

The part that confuses me comes afterwards. Namely, as $$E$$ is special the Riemann-Roch tells us that $$\dim |E| \geq d-1-g$$, and similarly that $$\dim |E+Q+P| = d-g$$. Because the difference between these two dimensions is at most 1, this somehow implies that the set of divisors $$S$$ as above has dimension $$\leq g+2$$.

I don't understand this implication. We have divisors of the form $$E+Q+P$$, each of which gives a linear system of dimension $$d-g$$, and all of which form a set of divisors of dimension $$\leq g+1$$. How does the difference in dimension of $$E$$ and $$E+P+Q$$ tell us the dimension of $$S$$?

Write $$\mathrm{Pic}^d(X)$$ for the scheme which parametrized all line bundles of degree $$d$$ on $$X$$, $$\mathrm{Div}^d(X)$$ for the scheme which parametrized all effective divisors of degree $$d$$ on $$X$$, and $$D_{\mathrm{univ}}\subset X\times \mathrm{Div}^d(X)$$ for the universal effective divisor of degree $$d$$. Then, by the universality of $$\mathrm{Pic}^d(X)$$, the line bundle $$\mathcal{O}_{X\times \mathrm{Div}^d(X)}(D_{\mathrm{univ}})$$ induces a morphism $$\varphi_d:\mathrm{Div}^d(X) \to \mathrm{Pic}^d(X).$$ This morphism can be written as $$\varphi_d(D) = \mathcal{O}_X(D)$$. Hence each fiber of $$\varphi_d$$ is linearly equivalent class. In particular, for any $$L\in \mathrm{Pic}^d(X)$$, it holds that $$\dim(\varphi_d^{-1}(L)) = \dim H^0(X,L) - 1$$.
Write $$\mathrm{SpDiv}^d\subset \mathrm{Div}^d(X)$$ for the closed subscheme determied by all special effective divisors. Then, by Riemann-Roch, for any $$D\in \mathrm{SpDiv}^d$$, it holds that $$\dim(\varphi_d^{-1}(\mathcal{O}_X(D))) = 1+d-g+l(K-D)-1 \geq 1+d-g.$$ Since $$\dim(\mathrm{SpDiv}^d) = g-1$$, it holds that $$\dim(\varphi_d(\mathrm{SpDiv}^d)) \leq (g-1)-(1+d-g) = 2g-2-d.$$
Now, let us consider the following two morphisms: \begin{align*} f:X\times X\times \mathrm{Div}^{d-2}(X)\to \mathrm{Div}^d(X), (P,Q,D)\mapsto P+Q+D, \\ g:X\times X \times \mathrm{Pic}^{d-2}(X) \to \mathrm{Pic}^d(X), (P,Q,L)\mapsto L\otimes \mathcal{O}(P+Q). \end{align*} Then we obtain the following commutative diagram: $$\require{AMScd} \begin{CD} X\times X\times \mathrm{SpDiv}^{d-2} @>{\subset}>> X\times X\times \mathrm{Div}^{d-2}(X) @>{f}>> \mathrm{Div}^d(X) \\ @. @V{\psi}VV @VV{\varphi_d}V \\ @. X\times X\times \mathrm{Pic}^{d-2}(X) @>{g}>> \mathrm{Pic}^d(X), \end{CD}$$ where $$\psi := \mathrm{id}_X\times \mathrm{id}_X \times \varphi_{d-2}$$. Write $$T:= g(\psi(X\times X\times \mathrm{SpDiv}^{d-2}))\subset \mathrm{Pic}^d(X)$$. Then $$\dim(T) \leq 2g-2-(d-2)+2 = 2g-d+2.$$ Since $$\dim(\mathrm{Div}^d)) = d$$, and $$\dim(\mathrm{Pic}^d) = g$$, the dimension of general fibers of $$\varphi_d$$ are $$d-g$$. Hence $$\dim(\varphi_d^{-1}(T)) \leq (2g-d+2)+(d-g) = g+2,$$ (where we note that if $$T \subset \varphi_d(\mathrm{SpDiv}^d)$$, then the dimension of general fibers of $$\varphi_d^{-1}(T) \to T$$ are $$>d-g$$, however, in this case, since $$\varphi_d^{-1}(T)\subset \mathrm{SpDiv}^d$$, it holds that $$\dim(\varphi_d^{-1}(T)) \leq \dim(\mathrm{SpDiv}^d) = g-1 < g+2$$). Moreover, by our construction, the scheme $$\varphi_d^{-1}(T)$$ parametrizes all effective divisors $$D\subset X$$ which are linearly equivalent to $$E+P+Q$$, the sum of a special effective divisor $$E\subset X$$ and points $$P,Q\in X$$. This is desired conclusion.