My program fails to recover the last JPEG. I see only 49 JPEGs. I checked it with Valgrind and had no memory leaks. I suspect it has something to do with EOF but I'm not sure... The code is: https://pastebin.com/art3pxmB Any suggestions?