fixed loop error when writing out samrecord reads