This prevents MemoryError when running on systems with less memory than the file being processed. Fixes #1051. Thanks @parkr