Fix chunk count

When a file only has two chunks, the count was wrong and the header was
missing

TODO:
- [ ] add unit test with 2 chunks