I had a file whose contents were copied from a word document. I added '#' characters for the headers, but the headers weren't being properly normalized.
It looks like what happened is that the line endings for the file were /r/r rather than the expected /r/n so the regex for normalizing the headers didn't correctly pick up the headers.