Solutions to Hartshorne's Algebraic Geometry/Riemann-Roch Theorem

Exercise IV.1.1
Let $$X$$ have genus $$g$$. Since $$X$$ is dimension 1, there exists a point $$Q \in X$$, $$Q \neq P$$. Pick an $$n > \max(g, 2g-2, 1)$$. Then for the divisor $$D = n(2P - Q)$$ of degree $$n$$, $$l(K - D) = 0$$(Example 1.3.4), so Riemann-Roch gives $$l(D) = n + 1 - g > 1 $$. Thus there is an effective divisor $$D' $$ such that $$D - D' = (f) $$. Since $$(f) $$ is degree 0 (II 6.10), $$D' $$ has degree $$n $$, so $$D' $$ cannot have a zero of order large enough to kill the pole of $$D $$ of order $$2n $$. Therefore, $$f $$ is regular everywhere except at $$P $$.