Added check about empty string
Merge pull request #8011 from malinoff/fix-no-output

Fix printing newline if there is nothing to print