clean up regex definition a bit
handle empty lines correctly