Correctly handle empty line between items

and don't add unnecessary newlines.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>