Regex now more accurate, also includes links at the end of a file without a trailing newline.