--- a/interpreter-3.x/trunk/kernel/RexxClasses/StreamClasses.orx
+++ b/interpreter-3.x/trunk/kernel/RexxClasses/StreamClasses.orx
@@ -369,7 +369,7 @@
 
 ::METHOD init                          /* initialization method             */
                                        /* access the state information      */
-expose stream position line available transient
+expose stream position line available transient close
 use arg stream                         /* get the stream                    */
 position = 0                           /* set initial position              */
 available = 1                          /* assume this is available          */
@@ -379,6 +379,10 @@
 else
   transient = .false                   /* we can read by position           */
 line = ''                              /* set a default line                */
+if stream~state == 'UNKNOWN' then      /* remember initial state            */
+  close = .true
+else
+  close = .false
 self~next                              /* get the first line                */
 
 ::METHOD next                          /* step to next element              */
@@ -397,6 +401,8 @@
 return                                 /* all finished                      */
 notready:                              /* notready condition occurred       */
 available = 0                          /* nothing available now             */
+if close then                          /* if stream originally unopened     */
+  stream~close                         /* then close the still open stream  */
 return                                 /* all finished                      */
 
 ::METHOD available                     /* is an item available?             */
@@ -468,4 +474,4 @@
 ::METHOD queue           EXTERNAL 'REXX rexx_queue_queue'
 ::METHOD pull            EXTERNAL 'REXX rexx_pull_queue'
 ::METHOD linein          EXTERNAL 'REXX rexx_linein_queue'
-::METHOD queued          EXTERNAL 'REXX rexx_query_queue'
+::METHOD queued          EXTERNAL 'REXX rexx_query_queue'