Fixed bug where padoc YAML markdown on the first line caused an error.

YAML frontmatter was causing an error when the table of contents script looked for the previous line for a header. This fix checks if the last line actually exists before refrerencing it.