I would approach this problem by writing code I could re-use. My goal would be:
1. read the file only once
2. produce a useful collection of "pieces" of the file based on the number of lines to read into each piece, and the number of pieces to be produced.
a. 'chunk: a List of string whose size is the number of lines the user specifies per chunk.
b. 'lineChunks: a collection of chunks.
3. deal in some way with the file being too "short" to read even one chunk, or the number of lines in the file not being integrally divisible by the chunk size.
private string filePath = @"C:\Users\YourUserName\Desktop\thirty.txt";
private List<list><string>> getLines(string fPath, int nChunks, int linesPerChunk)
{
var Lines = File.ReadLines(fPath);
var lineChunks = new List<list><string>>();
for (int i = 0; i < nChunks; i++)
{
var chunk = Lines.Skip(i * linesPerChunk).Take(linesPerChunk).ToList();
if(! (chunk.Count == 0)) lineChunks.Add(chunk);
}
return lineChunks;
}
</string></list></string></list>
To test this I created a Text file named 'thirty.txt' that had 30 lines; each line's content was a number from 1~30.
var chunkCollection1 = getLines(filePath, 2, 15);
var chunkCollection2 = getLines(filePath, 2, 30);
var chunkCollection3 = getLines(filePath, 2, 20);
var chunkCollection4 = getLines(filePath, 2, 59);
var chunkCollection5 = getLines(filePath, 2, 0);