in reply to First header missing from FASTA data

When you say if ($flag == 0) { ... next;} you are telling the program not to print the first header line. Remove that if block and it will. NYULMC?