front will not persist after popFront is called, so the caller must copy its contents (e.g. by
calling to!string) when retention is needed. If the caller needs to retain a copy of every line, use the byLineCopy function instead.
Parameters
Char | Character type for each line, defaulting to char. |
keepTerminator | Use Yes.keepTerminator to include the terminator at the end of each line. |
terminator | Line separator ('\n' by default). Use newline for portability (unless the file was opened in text mode). Example: Example: Notice that neither example accesses the line data returned by front after the corresponding popFront call is made (because the contents may well have changed). import std.stdio; version (Windows) void main() { foreach (line; File("file.txt").byLine(No.keepTerminator, "\r\n")) { writeln("|"~line~"|"); if (line == "HelloWorld") writeln("^This Line is here."); } } |