I already proved the following:
Lemma A: Let $K$ be a field. Let $t$ be transcendental over $K$. Let $f \in K[X] \backslash K$. Then $f(t)$ is transcendental over $K$.
Proof: Because $t$ is transcendental over $K$, we have by definition: $\forall p\in K[X] \backslash \{ 0\} : p(t) \neq 0$. Suppose $f(t)$ is algebraic over $K$. Then there is a polynomial $q\in K[X] \backslash \{0 \}$ with $q(f(t))=0$. Define $g:=q(f(X)) \in K[X] \backslash \{ 0 \}$. Note: $g(t)=0$. Contradiction. Thus, $f(t)$ is transcendental over $K$. QED
Now I try to prove this.
Lemma B: Let $K$ be a field. Let $t$ be transcendental over $K$. Let $x\in K(t)$. Then $x$ is algebraic over $K$ if and only if $x\in K$.
My attempts: I write $x$ as $x=\frac{f(t)}{g(t)}$ with $f$ and $g$ being polynomials over $K$. If $x$ is algebraic over $K$, then there is a polynomial $p\in K[X]\backslash \{ 0 \} $ with $p(x)=0$. This is the same as $p\left (\frac{f(t)}{g(t)} \right ) = 0$. Now, I want to prove that if $x\not \in K$, this leads to a contradiction, but I don't know how to tackle this. Can anyone give me a hint?
Note that $g(t)^N p \left( \frac{f(t)}{g(t)} \right) = 0 $ is a monic polynomial in $t$ for a suitable large enough $N$