Here is a sample console application that will accomplish this for you. You could get fancier and have it simply replace the existing file by opening the file and editing it in place if you want too.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
StreamWriter sw = new StreamWriter("NewFile.txt");
using(StreamReader sr = new StreamReader("textfile1.txt",Encoding.ASCII))
{
string line;
while (!sr.EndOfStream)
{
line = sr.ReadLine();
sw.WriteLine(line);
if (line.StartsWith("B"))
{
sw.WriteLine("\n\r");
}
}
}
sw.Close();
}
}
}
Here is what TextFile1.txt looks like:
Code:
A
B
C
D
E
F
G
H
I
J
K
L
M
Bookmarks