in reply to All of my terms end up in @foo0

One possibility is that something odd happens when you define @file. Not having seen the code, I'll guess that you have a problem with line endings; you're reading in a file containing file names on separate lines, but the mismatch in line endings means they get read in as a single value.

If that's not it, seeing more of the code would be very helpful.