added login to handle missing key value pairs based on static header row definition. Missing header values written at the end of the file for identification