Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
File.getline
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
| Type | Description |
string / undefined | Returns the next line (without the line break); returns |
See Also
Remarks
Read file content line by line in sequential order.