PHP fun (solution)
Well I found the solution on #php on irc.freenode.net. substr($ret , -5) was returning html when being the last 5 char is should of returned .html. I did notice this, but having never used the substr function before I didnt think much of it. So it turns out I was returning html\n (\n is 1 char). So it needed the trim function applied:
trim(substr($ret, -4);
Its just like Perls chop function, servers same purpose. There easy solution like I said.
-----