Given the following linear system
$$\left[\begin{array}{cccc|c} k & 0 & 1 & 2 & 0\\ -1 & 1 & k & 1 & 0\\ 1 & k & 1 & 3 & 0\end{array}\right]$$
find for which values of $k$ the system has none, one or infinitely many solutions.
I got to
$$\left[\begin{array}{cccc|c}1&k&1&3&0\\0&1+k&1+k&4&0\\0&-k^2&1-k&2-3k&0\end{array}\right]$$
but now I'm stuck. How do I eliminate $-k^2$ using $1+k$?
This is not the first time I got a question like this, how do I solve it?
To perform the second step in row reduction, you need to find the first non-vanishing element in the second row. That would be $k+1$ iff $k\neq-1$. In that case multiply the second row by $k^2$ and the third one with $k+1$ and add both.
Now if $k=-1$ you get $$\left[\begin{array}{cccc|c}1&-1&1&3&0\\0&0&0&4&0\\0&-1&2&5&0\end{array}\right],$$ which is easily solved.