writing a header to the txt file as well