How can a DXF file be validated?

I am developing an application similar to the Windows Search. It performs a recursive search, looks for some items inside the DXF file and proceeds to the next. There may be hundreds or even thousands of files, so expediency is a must.

My problem is that when confronted with an in invalid DXF file, the library -like the Energizer bunny- keeps going and going and going:

DXF read error: Line: 1
DXF read error: trying to fix..
[…]
and so on, and so forth…

It does not know when to quit: Even an empty file seems to be acceptable.

TIA,

-RFH