Merge into folders line by line, more memory efficient
Added tests for merge to folders