I'm not sure what you're describing, but I think I know what you're really asking, so let's try.
When scanning the data in the card.raw file, the code needs to search for the first block of 512 bytes that has a header signature. Everything before that is garbage data to throw away. From this point forward, all the data is good data.
Now, here's what I think you're trying to figure out. Once you've found a 512 byte block that has a signature, it's the start of the first image file. BUT, it's not the WHOLE file. Blocks of data that follow will not have the header signature, but they're more of the data in that file! Remember, most image files are a lot larger than 512 bytes!
This means that all data blocks that follow the one with a signature are part of the same image file. Once the code finds the next header signature, that means that the data block with the signature is the beginning of the next file. Time to close the current file and open the next file.
Does that explain what's going on?
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)