# why does ReadString[“fname”,term] open a persistent stream, and how to close it?

Bug introduced in 10.0 and fixed in 10.3.0

Create a file temp.txt with the following content:

test1
;;;
test2
;;;
test3
;;;


Treating the semicolon sequence as terminator, try to repeatedly read to the first terminator.

Table[ReadString["temp.txt", "\n;;;"], 6]


Contrary to my intent, this does not create a list holding "test1" 6 times. Instead, it keeps reading the file to the next terminator, and starts over when it reached the end-of-file.

1. How can I understand the documentation to imply this behavior?
2. Is there a stream object hiding somewhere? (It is not listed by Streams[].) If so, can it be closed?
3. How can I most simply achieve the desired behavior? (Most simply means something more aesthetic than the following.)

..

Table[x = ReadString["C:/temp/temp.txt", ";;;"];

• I can confirm that the behavior with 10.2.0, 10.1.0 and 10.0.2 (ReadList was new in v10 I think) is as Alan describes while it is as he expects in 10.3.0, both on the same Windows 7 (64bit) machine. So it looks like it is a bug which has been corrected for 10.3. – Albert Retey Jan 24 '16 at 17:25