I really thought I had basic algebra figured out, but I was trying to provide an argument as to why this is true, and I don't know how to justify it.
If $x=0$, then $1/x$ is undefined, but I am also quite sure that $\frac{1}{x} - \frac{1}{x} = 0$.
Is $y-\frac{1}{x} = f(x) - \frac{1}{x}$ defined at $x=0$? If not, then how can it be equivalent to $y = f(x)$, which is defined at $0$?
Though $$y-\frac1x=f(x) - \frac1x$$ doesn't make sense when $x=0$, if $f$ and $y$ are continuous and defined at $0$ the fact that they are equal everywhere else implies that they are also equal at $0$.
When software like Mathematica does algebraic manipulation, sometimes it does it without regard to whether the expression is defined at all values, though I have seen it do things like specify $x\neq 0$ in this case. In a certain context, such manipulations are completely correct, such as when we have no intention of substituting anything into $x$ and we are working in the field of rational functions. For your context this is not the case, and we must ensure that $x\neq 0$.