update headers and delete empty lines