Added support for modelines at end of file

Modelines at beginning of file will be parsed before lines at the end of
the file. Parsing stops at the first modeline encountered, so in essence
modelines at the beginning of the file override modelines at the end of
the file.