Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
os
File
File.close
File.puts
File.printf
File.flush
File.tell
File.seek
File.eof
File.read
File.write
File.getline
File.toString
ListFilesResult
FileStat
Structures
Built-in Variables and Constants
Conventions
Exchanges

Read the next line from the file.

getline()

Examples

Read file line by line until the end.

javascript
function main() { let file = os.open("data.txt", "r") let lineCount = 0 let line while ((line = file.getline()) !== undefined) { lineCount++ Log("Line", lineCount + ":", line) } Log("Total lines:", lineCount) file.close() }

Returns

TypeDescription

string / undefined

Returns the next line (without the line break); returns undefined once all content has been read. An empty line in the file returns an empty string "".

See Also

Remarks

Read file content line by line in sequential order.