(fixes #11) Fix an error when a chunk ends in the middle.