How about any place earlier than the penultimate line in the proof you are asking about?
As you were told, if a function is continuous, you can substitute; you can't substitute when it is not continuous, and in particular when it isn't even defined there.
In many instances of working out a limit, the process amounts to rewriting and simplifying until you get a new function that is equal to the original everywhere except the place where it previously was undefined, but now is defined and continuous there. Then you can substitute.