Improve header regex so that it doesn't require a trailing newline
Skip empty header lines when processing directives