Theorem on the Dimension of Fibers for locally closed an open sets

I map a locally closed set $X$ on an open set $Y$ by a polynomial map $f$. I know that for $y\in Y$, $\dim f^{-1}(y)=0$ (finite number of points).

Is it true that $\dim X = \dim Y$?

I found the Theorem on the Dimension of Fibers in Shafarevich's book Basic Algebraic Geometry (Theorem 7 on p. 76) but it works under assumptions that both $X$ and $Y$ are irreducible varieties and in my case $X$ is just a locally closed set, and $Y$ is a nonempty open (and hence irreducible).

You can try restricting to the connected components of $X$. Say $X = \cup Z_i$ where $Z_i$ are the necessarily finitely many irreducible components. Then consider the restriction of $f$ to $Z_i$.
Using the dimension of fibers theorem, which we can now apply since $Z_i$ is irreducible, we see that a generic fiber of $f: Z_i \to Y$ has dimension $\dim Z_i - \dim \overline{f(Z_i)}$. This is $0$ by assumption so $\dim Z_i = \dim \overline{f(Z_i)} = \dim f(Z_i)$.
Thus, $\dim Z_i = \dim f(Z_i)$ for every component of $X$ and $f$ is surjective by your assumption so $\dim X = \dim Y$.