For positive genus, $\ell(A)=\deg(A)+1\Leftrightarrow A$ is a principal divisor (this is exercise $1.8$ from Stichtenoth's Algebraic Function Fields and Codes)

Let $F|K$ be a function field in one variable with genus $g>0$. If $A$ is a divisor with $\ell(A)>0$, show that $\ell(A)=\deg(A)+1\Leftrightarrow A$ is a principal divisor.
(Notation: $\ell(A):=\dim_K\mathcal{L}(A)$, where $\mathcal{L}(A):=\{z\in F\mid (z)\geq -A\}\cup\{0\}$)

Here's my attempt:
$(\Leftarrow)$ If $A=(z)$ then $\deg(A)=0$. Besides, $A\sim 0$, so that $\mathcal{L}(A)=\mathcal{L}(0)$ and $\ell(A)=\ell(0)=1$. That way, $\ell(A)-\deg(A)-1=1-0-1=0$.
$(\Rightarrow)$ If $\ell(A)-\deg(A)-1=0$, then for a canonical divisor $W$ we have by Riemann-Roch that $\ell(W-A)=g$. Besides, $\deg(W-A)=\deg(W)-\deg(A)=2g-2-\ell(A)+1\leq 2g-2$.
If I could show that $\deg(W-A)$ is exactely $2g-2$, this would prove that $W-A$ itself is a canonical divisor, so that $A$ is necessarily principal.
I can't see how would I prove the inequality $\deg(W-A)\geq 2g-2$.
Any suggestions?
(different strategies will also be welcome)
 A: You don't need Riemann Roch.


*

*$\ell(D) \le \ell(D-Q)+1$ because once we have one $u \in L(D), \not \in L(D-Q)$ for 
all $v \in L(D)$ we have $v- C u \in L(D-Q)$ for some $C$.

*Moreover $\deg(B)=0, \ell(B)=1 \implies L(B) = Kf$ and $\forall P, \deg(B-P) < 0\implies\ell(B-P) =0 \implies div(f)=B$
Given $\ell(A) = \deg(A)+1$, if $\deg(A)>0$


*

*pick some $Q_1$ not appearing in $A$ such that one element of $L(A)$ doesn't have a zero at $Q_1$  then $\ell(A-Q_1)< \ell(A)$ so that $\ell(A-Q_1)=\ell(A)-1$,
do it repeatedly to obtain $\ell(A-\sum_{j=1}^n Q_j) = \ell(A)-n,\ell(A-\sum_{j=1}^{\deg(A)} Q_j) = 1$

*$A-\sum_{j=1}^{\deg(A)} Q_j = div(g)$ so that $\ell(Q_{\deg(A)}) = \ell(Q_{\deg(A)} + div(g) ) = 2$ which means there is a function $h$ with only one (simple) pole  at $Q_{\deg(A)}$ : this implies the function field is $\overline{K}(h)$ of genus $0$
A: There is a proof without too much preliminaries except

Lemma. If $A$ and $B$ are divisors of $F/K$ with $A\ge B$, then $\mathcal L(B)$ is a subspace of $\mathcal L(A)$, and
$$\ell(A)-\ell(B)\le\deg(A)-\deg(B).$$

Proof. Suppose $\ell(A)=\deg(A)+1$ and $\deg(A)>0$. Since $\ell(A)>0$, there exist an element $z\in\mathcal L(A)$ with $A+(z)\ge0$, and a place $P$ with $A+(z)\ge P$. Note that
$$\deg(A)+1-\ell(P)=\ell(A)-\ell(P)\le\deg(A)-\deg(P),$$
but $\ell(P)\le\deg(P)+1$. Thus $\ell(P)=\deg(P)+1$, and there exists a basis $1,\beta_1,\dots,\beta_{\deg(P)}$ of $\mathcal L(P)$ over $K$. The rest is to prove by induction that $\ell(kP)=\deg(kP)+1$ for all $k\in\mathbb N^*$, a contradiction to Riemann's Theorem.
Assume $\ell(kP)=\deg(kP)+1$ for a positive integer $k$. Choose an element $t\in F$ with $v_P(t)=1$ and $v_{P^\prime}(t)\le0$ for all other places $P^\prime$ (e.g., $t=\beta_1^{-1}$). Then $v_P(\beta_it^{-k})=-k-1$ and $v_{P^\prime}(\beta_it^{-k})\ge0$ for $1\le i\le\deg(P)$, so that $\beta_it^{-k}\in\mathcal L((k+1)P)\setminus\mathcal L(kP)$. If
$$\sum_{i=1}^{\deg(P)}a_i\beta_it^{-k}\in\mathcal L(kP)$$
for $a_i\in K$, then
$$v_P\left(\sum_{i=1}^{\deg(P)}a_i\beta_i\right)\ge0.$$
It follows that $\sum_{i=1}^{\deg(P)}a_i\beta_i\in K$, which means $a_i=0$ for $1\le i\le\deg(P)$, and then
$$\mathcal L(kP)\cap\langle\beta_1t^{-k},\dots,\beta_{\deg(P)}t^{-k}\rangle=\{0\}.$$  Moreover, $\beta_1t^{-k},\dots,\beta_{\deg(P)}t^{-k}$ are linearly independent over $K$, so $\ell((k+1)P)-\ell(kP)\ge\deg(P)$. Thus
$$\ell((k+1)P)=\ell(kP)+\deg(P)=\deg((k+1)P)+1.$$
A: I think I've found a simpler solution for ($\Rightarrow$).
Since $\ell(A)>0$, we may assume $A\geq 0$, so $\deg(A)\geq 0$. Notice that if $\deg(A)\geq 2g-1$ we have by Riemann-Roch that $g=\deg(A)-\ell(A)+1=0$ (absurd, since $g>0$). Therefore $0\leq \deg(A)\leq 2g-2$ and we may apply Clifford's theorem:
$$\ell(A)\leq 1+\frac{1}{2}\deg(A)=1+\frac{1}{2}(\ell(A)-1)$$
from which we get $\ell(A)\leq 1$. But $\ell(A)>0$, so $\ell(A)=1$ and $\deg(A)=0$, so $A$ is principal. $_\square$
