Let us first analyze the statement $$\lim_{x\to a} f(x) \neq f(a) \tag{1}$$ which says that there exists an $\epsilon >0$ such that for every $\delta>0$ there is at least one corresponding value of $x$ satisfying both $0<|x-a|<\delta$ and $|f(x) - f(a) |\geq \epsilon$.
So we first have an existence of an $\epsilon $ and that means it is a fixed positive number. Next let us concentrate on the phrase "for every $\delta>0$ there is at least one corresponding value of $x$" and that means we can choose any arbitrary value for positive $\delta$ giving rise to infinitely many choices of $\delta$. It may however happen that for all these choices of $\delta$ we may just have a single $x$ which works. NO, this won't happen and in fact we can ensure that for each value of $\delta$ we get get a different corresponding $x$. Let us take one value of $\delta$, say $\delta_1$ arbitrarily and we are ensured a specific value of $x$, say $x_1$ corresponding to it such that $0<|x_1-a|<\delta_1$. Next we choose $\delta_2=|x_1-a|$ and then the corresponding $x_2$ will satisfy $$0<|x_2-a|<\delta_2=|x_1-a|$$ so that $x_2$ is nearer to $a$ than $x_1$ and hence different from $x_1$. Continuing in this fashion we get a sequence $x_n$ of distinct values of $x$ with each term being nearer to $a$ than the previous term. And further the starting value $x_1$ is based on an arbitrary choice $\delta_1$ which can be as small as we desire, it follows that there are infinitely many values of $x$ in every neighborhood of $a$ for which the inequality $|f(x) - f(a) |\geq \epsilon$ holds.
Out of these infinitely many values of $x$ some will satisfy $f(x) \geq f(a) +\epsilon$ and some will satisfy $f(x) \leq f(a) - \epsilon$. And then one of these cases must be satisfied by an infinitely number of values of $x$. And then Spivak handles one case implying that the reader can supply a similar argument for another case. Once a particular case is chosen, say $f(x) \geq f(a) +\epsilon$ we can observe that the infinitely many values of $x$ satisfying it are either less than or greater than $a$ and again there must be infinitely many values of $x$ satisfying at least one of the conditions $x<a$ or $x>a$. Spivak again chooses $x>a$ here and leaves $x<a$ for readers.
Thus Spivak handles the case when there are infinitely many values of $x$ arbitrarily near to and greater than $a$ for which $f(x) \geq f(a) +\epsilon$. Depending on the function one may have to handle remaining three cases as well, but the argument is similar and left for the reader to supply. And in his argument he finds three values of $x$, namely $x, x'$ and $y$ (it would have been better to call it $x''$ instead of $y$) and obtains a contradiction. A similar contradiction can be obtained by choosing three suitable values of $x$ in other remaining three cases as well. You can try other cases and note that argument requires only reversal of inequality signs in appropriate places.
In case this comes up in a test I will personally not require the students to write similar arguments for all four cases when the only difference between these cases is the sign of some inequality. The grading should be done by taking into account how the student uses the injective nature as well as intermediate value property of the function to arrive at the desired conclusion. But then I am not in academic profession and different professors may have different expectations from students in a test.