It's been a rather long discussion already, but it seems that
you haven't given any of the context that precedes the
"system()" line in the original post. Are you sure that
the "final output file" that results from the preceding
steps really exists with the expected content when 3 or more
input files are involved?
How sure are you that your script isn't dying quietly at some
point before "system" (and the other diagnostics you've
tried now) when you have 3 or more input files?