links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Recipe: Doing something with each line in a file
Last updated at 11:06 am UTC on 31 May 2016


You want to process a text file line by line. You don't want to worry about different line end characters in different operating systems.


Create an instance of a MultiByteFileStream on the file:

 file := FileStream fileNamed: 'test.txt'.

         [file atEnd] whileFalse:
                [line := file nextLine. "Process the line"]


The MultiByteFileStream does its job in a platform independent way.

See also

Regular Expressions in Squeak if you want to do more complicated things to each line.