I have a cheap second hand nylon string guitar, which had very old and horrible strings on it, so I changed them. All was fine, until I tried to put on the new high e string. It won't tune up far enough, no natter what I do. When i tune it, at some point the string invariably loses its tension. At first I thought it was a problem with the bridge, however I noticed that it just unwraps from the tuning peg, with the loose end being pulled through.

I am a bit of a noob, but the other 5 strings are working perfectly, so I don't think it is my error. So my question is, what can I do to make the string keep its tension?

Thanks in advance.
Yeah, I could do but I am a bit short of cash, besides it seems like a waste of an otherwise ok guitar if it would be an easy fix. Probably will head that way though.
I think there is a particular way to lock the string in the post on a nylon string guitar, but I don't remember. I never got into them, but if it's slipping through the post hole, that's probably what it is.
"Life's too short for bad tone"-Rev. Billy Gibbons
Yeah, I did a little research and one person suggested buying a new string and trying again, worked a treat! Not sure why though. Thanks for the help!