EOF tidy-up and index bug fix.

Sanitised the setting of fd->empty_container into one place. This also fixes the samtools bug #146.

https://github.com/samtools/samtools/issues/146