TITLE: An element of $f$ of a function field such that $P$ is the only pole of $f$.
QUESTION [6 upvotes]: Let $F$ be a function field in one variable over a field $k$. Let $S$ be a nonempty finite subset of all places of $F$. Prove that if $P \in S$, there is an element $f$ of $F$ such that $P$ is the only pole of $f$.

REPLY [2 votes]: Let $X$ be the smooth projective curve with $F=k(X)$, and suppose that it has genus $g$. Let $S=\{x_1,\ldots,x_m\}$ and let $D_{(n_1,\ldots,n_m)}$ be the divisor
$$\sum_i n_i x_i$$
for $(n_1,\ldots,n_m)\in \mathbb{Z}^m$. Then, just as a way of recognizing the reasoning for the below approach, note that
$$O_S=\bigcup_{(n_1,\ldots,n_m)}\mathcal{O}(D_{(n_1,\ldots,n_m)})(X)$$
So, I assume that in your question you want $P\in S$, not $P\in X$--definitionally if $P\notin S$, then any $f\in O_S$ does not have a pole at $P$. So, let us assume, without loss of generality, that $P=x_1$. Consider then the divisor 
$$D_{(n,0,\ldots,0)}$$
Note that if we take $n\gg 2g$ then $\mathcal{O}(D_n)$ is globally generated (see, e.g. 19.2.11 here). So, let $f\in\mathcal{O}(D_{(n,0,\ldots,0)})(X)$ be non-zero. Then, by definition
$$\mathrm{div}(f)+nP\geqslant 0$$
This says that $f$ only has a pole at $P$, and thus of course, it's also in $O_S$. Taking $n$ sufficiently large also guarantees (by Riemann-Roch) that the global sections of $\mathcal{O}(D_{(n,0,\ldots,0)})$ will have arbitrarily large dimension. Thus, we can assume that $f$ is non-constant as well, which implies that not only is its only pole at $P$, but that it has a pole at $P$.
Remark: I assume that this exercise is so you can show that $X-\{P\}$ is affine?