I tried to convert the SAM file generated by Bowtie(1.2.3) to BAM file with samtools(1.9), but I met the following warnings and errors:
[W::sam_hdr_sanitise] Missing trailing newline on SAM header. Possibly truncated
[E::sam_hdr_error] Missing tab at line 32: "@HISEQ:154:CB8RGANXX:1:2101:1470:1000    16    Fvb7    20495637    255    16M    *    0    0    GTTGTGCTACAGCGGN    IIIIIIIIIIIIIIII    XA:i:1    MD:Z:15A0    NM:i:1    XM:i:3" 
[main_samview] failed to write the SAM header
but when I use cat -A to check the newline in my sam file, it looks normal that a $ character appears at every line end. Here is the header region of my sam file : 

I think there maybe some problems with my sam file. The commands I used are as below:
bowtie-build -f ref.fasta index 
bowtie -f -v 1 -p 8 -S -a -m 50 --best --strata index s3-7-6-hua-2_clean.fa s3-7-6-hua_clean.sam --sam-RG ID:s3-7-6-hua-2_clean
samtools view -bS s3-7-6-hua_clean.sam  >s3-7-6-hua_clean.bam
Appreciated for any help!QAQ
the message is about a tab, not about a newline.
did you use any tab instead of spaces in the command "bowtie -f -v 1 -p 8 -S -a -m 50 --best --strata index s3-7-6-hua-2_clean.fa s3-7-6-hua_clean.sam --sam-RG ID:s3-7-6-hua-2_clean" , it could mess the @PG line in the header.
Thank you for your help:D! It turns out that the '@' character brings the problem~