chunking files to avoid OutOfMemoryExceptions