Reading Specific Lines of a Text File

You can read a specific line of a text file by entering a line number as an argument on the LINEIN method. In this example, line 3 is read from CONFIG.SYS:

/* Read and display line 3 of CONFIG.SYS */
infile=.stream~new('c:\config.sys')
say infile~linein(3)

You don't necessarily reduce file I/O by using specific line numbers. Because text files typically do not have a specific record length, REXX must read through the file counting line-end characters to find the line you want.


[Back: Reading a Text File into an Array]
[Next: Writing a Text File]