Prevent infinite loops in malformed PDFs

The error is if you have a PDF file that has no newlines, carriage returns, or "%%EOF" markers. If someone inputs a file with content "%PDF" , there will be an infinite loop instead of an error.