dpkg warns: unable to delete old directories (not empty):|dpkg: warning: unable to delete old directory '"'"'([[:print:]]+)'"'"': Directory not empty|\1
 update-alternatives: providing in auto mode:|update-alternatives: using ([[:print:]]+) to provide ([[:print:]]+) \(([[:print:]]+)\) in auto mode| [\1 → \2 (\3)]'
 
+print_nl_if_started_printing() {
+    if [ ! -z "${_STARTED_PRINTING}" ]; then
+        printf '\n'
+    fi
+}
 _LAST_PREFIX=''
 _STARTED_PRINTING=
 eval "DEBIAN_FRONTEND=noninteractive apt-get -y $1; echo ${_FINISH_LINE}" 2>&1 | while read _LINE; do
     if [ -z "${_LINE}" ]; then
         continue
     elif [ "${_LINE}" = "${_FINISH_LINE}" ]; then
-        test ! -z "${_STARTED_PRINTING}" && printf '\n'
+        print_nl_if_started_printing
         printf '\r'
         break
     fi
     if [ "${_COMPRESSED_ITEM}" = "IGNORE" ]; then
         continue
     elif [ -z "${_COMPRESSED_ITEM}" ]; then
-        test ! -z "${_STARTED_PRINTING}" && printf '\n'
+        print_nl_if_started_printing
         printf '\r%s' "${_LINE}"
         _LAST_PREFIX=''
     else
         if [ "${_PREFIX}" != "${_LAST_PREFIX}" ]; then
-            test ! -z "${_STARTED_PRINTING}" && printf '\n'
+            print_nl_if_started_printing
             printf '\r'
             prefixed_msg_no_nl "${_PREFIX}"
             _LAST_PREFIX="${_PREFIX}"