final SAMFileHeader header = in.getFileHeader();
if (header.getTextHeader() != null) {
writer.write(header.getTextHeader());
} else {
// Headers that are too large are not retained as text, so need to regenerate text
new SAMTextHeaderCodec().encode(writer, header, true);
}
for (final SAMRecord rec : in) {
if (printStream.checkError()) {
return 1;