while condition question..

a cellphone company updates its data in a daily basis.
the main file of all customers if updated till yesterday
each line in this file has
20 chars name
9 chars Social security number
10 chars cell phone number
20 chars address
2 chars type of customer
8 chars date when the customer left the company
the file is sorted by cellphone number in ascended order.

each day the company makes another two files
one file is the file of new customers or present customers which changed their type.
regarding first file:

the first line is the date of the last update on this file.
20 chars name
9 chars Social security number
10 chars cell phone number
20 chars address
2 chars type of customer
8 chars date when the customer left the company
10 chars the name who wrote the update
the file is sorted by cellphone number in ascending order.

the second file is the list of people who left the company.
regarding the second file:
the first line is the date of the last update on this file.
10 chars cell phone number
10 chars the name of the man who wrote the update
the file is sorted by cellphone number in ascending order.
all the fields are sticked together without any space between them.

write a function which which takes the 3 files and creates a new file
which in the new main file.