This is always wrong except in the case of infinitely many repeated digits, and the proof does not explain this.
More rigorously, let 9.999{n} denote an expansion with n 9s after the decimal point, where n can also be infinity. The subtlety with the argument is that it needs X to be the same as everything after the decimal point (so that the result of the subtraction is just 9). This is never true for finite values of n, and the proof does not establish that it's true for an infinite value of n -- indeed, it can't do so without supplying a meaning in the first place.
Another way of phrasing it is that it assumes that if X = 0.999..., then 10X = 9.999..., where there are the "same number" of 9s after the decimal point in 10X as there are in X. This seems intuitive for an infinite repeating sequence of 9s, because "one less than infinity" is still infinity, but it's not very rigorous, and the argument as written certainly doesn't explain this.