The complete read routine would work before figuring out that it is a file of xml mimetype. This means that it would try to read to memory any file as the first thing, pdfs, even binaries. Of course doing so crashed the program.
Added heuristic which checks for the existence of a specific meta tag written to the pocketbook XHTML file.