Another try to fix empty lines

It turns out the matched patterns can overlap...