Thank you... I understand the iteration part of it but I did not get the point: "(presumably you have path information in the samples.txt file)."
So, what I have is only one library of pooled samples that contain both cases and controls (200 in total). The sample list is only the ID names in one column. I wanted to add all the 200 names into the bam header and then separate the bams based on cases and controls.