I have been summoned with the task of taking a tab delimited file and converting that file so it can be read by a third-party program. I am trying to think of the best way to do this, but I am having a hard time. Here is a view of the raw data that must be altered:

Code:
fkstoreid	HeaderMark	B1	RegNo	dateofbusiness	NoRegEntries	Tips	OverRings	Voids$	Voids#	NetSales	DP1_2Guests	DP3Guests	DP4Guests	DetailMark	fkdaypartid	RecType	GL	B2	Sales
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	2	0	41005	NULL	2220.25
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	3	0	41005	NULL	9170.19
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	4	0	41005	NULL	670.75
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	2	0	42100	NULL	52.03
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	3	0	42100	NULL	398.34
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	4	0	42100	NULL	137.94
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	2	0	43000	NULL	78.92
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	3	0	43000	NULL	311.93
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	4	0	43000	NULL	163.74
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	2	0	44000	NULL	10.98
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	3	0	44000	NULL	44.23
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	4	0	44000	NULL	12
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	2	0	41950	NULL	247.33
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	3	0	41950	NULL	867.89
1061	H	NULL	1	01/01/2008	NULL	NULL	NULL	113.26	35	12785.47	144	531	37	D	4	0	41950	NULL	38.54
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	2	0	41005	NULL	1998.09
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	3	0	41005	NULL	5950
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	4	0	41005	NULL	449.91
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	2	0	42100	NULL	65.58
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	3	0	42100	NULL	402.47
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	4	0	42100	NULL	94.51
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	2	0	43000	NULL	51.08
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	3	0	43000	NULL	376.61
1061	H	NULL	1	01/02/2008	NULL	NULL	NULL	129.78	42	9168.35	143	361	23	D	4	0	43000	NULL	65.79
So, each date will have a header (denoted by "H"). With this table every record has an "H." This is not the way it needs to be. I need to compare dates and when they differ, create a new header and make the rest of the data (if any) a detail (denoted by "D").

I am toiling with the best way of doing this. So far, I am not having much luck. I have used arrays quite successfully in Java, but I am not sure that this is the best way to go here. I would have to get how many lines there are and read each line. Make the changes, and then go on to the next line. I think scanning the document line by line using a loop is the best way. However, I am not sure.

I am in need of some opinions. What do you think I should?