NOT CONFIDENT see extended description

changed the program so it writes a header on the data. I am not sure if this program works as it should. I will test and make corrections ASAP.