Not much is being duplicated as far as I can see.
Not a huge amount, no, but when you start putting encoding there, you may find that modifying all the places you generate these files is more work than modifying it in one place.
Each "file" generated is different
Sure, but creating the filehandle, writing it out, closing it, checking for errors, all of that is the same.
Like I said, I wouldn't worry about it until your test file gets much larger. It's just a matter of taste at this point.