Following is from Smith's Algebraic Geometry book:
Let $S$ be a line segment in $\mathbb{C}$. Let $I \in \mathbb{C}[X]$ be the ideal of all polynomials that vanish on $S$. Then the closure of $S$ is the set of points where the polynomials in $I$ all vanish - i.e., $V (I)$. But nonzero polynomials vanish on finite sets of points and $S$ is infinite. It follows that $I = (0)$ i.e., the only polynomials that vanish on $S$ are identically zero. Since $V ((0)) = \mathbb{C}$, we get that the closure of $S$ is all of $\mathbb{C}$, as is the closure of any infinite set of points.
How "It follows that $I = (0)$" is correct? It can be an infinite number of polynomials in $I$? I know nonzero polynomials vanish on finite sets of points but how it is related to the conclusion that stated?
The ideal can indeed have infinitely many polynomials, but each must vanish on $S$, so $f\in I$ must satisfy $f(s)=0$, for every $s\in S$. In particular, each $f\in I$ must have infinitely many roots.