Here it is the solution. I even tested for you.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadFromFile
{
class Program
{
static void Main(string[] args)
{
string[] lines = System.IO.File.ReadAllLines(@"C:\tmp\WriteLines.txt");
List<string> result = new List<string>();
System.Console.WriteLine("Contents of WriteLines.txt = ");
string temp = "";
for (int i = 0; i < lines.Length; i++)
{
if ((i+1) % 5 == 0)
{
result.Add(temp);
temp = "";
}
else
{
temp += lines[i];
}
}
foreach (string s in result)
{
Console.WriteLine(s);
}
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
}