Reading a file into memory resulted in depletion of memory. Now files are read and written lazily, by chunks.