Hm, I am not sure to understand. Do you mean that you want to run an
statement in append mode for each line with a different chromosome in the input file? That would be very inefficient, as opening a file takes some time. You might want to dynamically open files only if you need to, but then you really want to open files only if they have not been opened before. From the OP, however, it seems that the program is receiving the list of chromosomes used in the file as an argument to the program.