You should use brackets appropriately. I have made the relevant changes in your question.

We need to prove that (cos x - sin x + 1)/(cos x + sin x -1) = cosec x + cot x

Start from the left hand side:

(cos x - sin x + 1)/(cos x + sin x -1)

=> (cos x - sin x + 1)(cos x + sin x + 1)/(cos x + sin x - 1)(cos x + sin x + 1)

=> [(cos x + 1)^2 - (sin x)^2]/[(cos x + sin x)^2 - 1]

=> [(cos x)^2 + 1 + 2*cos x - (sin x)^2]/[(cos x)^2 + (sin x)^2 + 2*(sin x)(cos x) - 1]

=> [(cos x)^2 + 1 + 2*cos x - (sin x)^2]/[ 2*(sin x)(cos x)]

=> [(cos x)^2 + (cos x)^2 + 2*cos x]/2*(sin x)(cos x)

=> [2*(cos x)^2 + 2*cos x]/2*(sin x)(cos x)

=> 2*(cos x)^2/2*(sin x)(cos x) + 2*cos x/2*(sin x)(cos x)

=> cos x/sin x + 1/cos x

=> cot x + cosec x

which is the right hand side

**This proves that (cos x - sin x + 1)/(cos x + sin x -1) = cosec x + cot x**