Remove debugging statement, change method of getting end of document.