I worked it out to it doesn't work if Line2 has a negitive gradient.

I'm gonna try and fix it now....