How can you tell if you're at the end of an incomplete blk*.dat file?
It is perfectly possible that *.blk files contains gaps of zeroes, or even partially written blocks. In modern versions (since 0.10 or so) this won't happen during normal operations, but it can't be prevented in case of abnormal shutdown (crash, out of disk space, ...).

If you want to be sure, you need to scan the entire file for potential blocks (they'll always start with a magic + length descriptor, so you can quickly skip many things). That, or use the getblock RPC instead, which uses Bitcoin Core's prebuilt index.