By the way, the error wasn't reported at the end of the file
Judging by the byte position (377), it was (the closing angle bracket of </ROOT> is byte 375(*)). I don't know why the line number is reported one less than it should be — maybe the <?xml ...?> header isn't being counted.
As for your other point, I think you're right if the parser would keep track of all starting positions of so far unclosed tags.
___
(*) assuming unix newlines, which I did after having seen i386-linux-thread-multi in the OP's error message.