Fix possible exception

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1736030 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
index 304485c..7330f67 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Closure.java
@@ -334,7 +334,7 @@
                 return result;
             } else {
                 String s = baos.toString();
-                while (s.charAt(s.length() - 1) == '\n') {
+                while (!s.isEmpty() && s.charAt(s.length() - 1) == '\n') {
                     s = s.substring(0, s.length() - 1);
                 }
                 return s;