Invalid XML Generated

I am generating a xml file by adding a “.xml” extension to a text file. It looks like valid. But when I parse it, it says, “Content is not allowed in prolog”. So, I checked that file in hex editor and found that it has some strange characters at the beginning. How do I remove those characters?