Having trouble taking this seemingly simple limit..

I'm having trouble taking this limit which should definitely be really simple. It looks as follows:

limit as x goes to 1 of (1 - x + lnx)/(1 + cos pi x)

This should probably use l'hopital's rule, since it goes to 0/0 so I take the derivative and get (-1 + 1/x)/(-sin pi x) which equals (-1 + x^-1)/(-sin pi x). This is 0/0 again, so I take l'hopital's rule again. I get (x^-2)/cos pi x. This is -1 as x approaches 1. However, I know this is wrong.

Where have I gone wrong?

Also, how are math equations done on this forum properly? Does it use TeX?