updated export function to write according to headerConfigs