Fix bug where the last chunk of JSON is dropped