Plainly, your program spins off inaccessible chunks of memory each time that it reads a file other than the first. If your program does nothing to reclaim those chunks, it eventually will run out of memory.
Whenever a chunk of memory becomes inaccessible, that chunk of memory is called garbage. Whenever a program creates garbage, the program has a memory leak.