With the latest change, *val will be \n after the last item, so this avoids an extra loop through the loops.