These two need an extra .strip() before the split, to avoid a trailing element with an empty line (which won't match the RE below).