Javascript FileSystemObject (FSO) textstream object provides a property called AtEndOfLine that returns the status of file reading pointer whether it is at the end of any line in the textstream. FSO OpenTextFile method supports the AtEndOfLine property when file is opened with FileReading mode. AtEndOfLine property returns the Boolean result i.e. true or false based on the position of the textstream file reading pointer. If file pointer is at the end of any line then it returns true otherwise it returns false. 

Syntax for Javascript FSO textstream AtEndOfLine property

textStreamObj.AtEndOfLine;

textStreamObj can be initialized using FileSystemObject and its OpenTextFile method that will return the textstream retrieved from the specified text file.

Example of FSO textstream Object AtEndOfLine property

<script type="text/javascript">
    // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
    var fso = new ActiveXObject("Scripting.FileSystemObject");

    // Open the text file at the specified location with write mode
    var txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 2, false, 0);
    txtFile.WriteLine("Hello this is the first line of text file.");
    txtFile.WriteLine("Hello this is the second line of text file.");
    txtFile.WriteLine("Hello this is the third line of text file.");

    txtFile.Close();

    // Open the text file at the specified location with read mode
    txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 1, false, 0);

    var text;

    // read 1st character of first line of the text file
    text = txtFile.Read(1);

    // returns the status of AtEndOfLine property
    document.write("<b>AtEndOfLine :</b> " + txtFile.AtEndOfLine);
    document.write("<br />");

    // while loop used to read characters 1 by 1 with condition AtEndOfLine!=true
    // this loop will work until AtEndOfLine=false and will exit the loop when AtEndOfLine=true
    while (txtFile.AtEndOfLine != true) {
        text += txtFile.Read(1);
    }

    document.write("<b>String returned :</b> " + text);
    document.write("<br />");

    document.write("<b>AtEndOfLine :</b> " + txtFile.AtEndOfLine);
    document.write("<br />");

    txtFile.Close();
    fso = null;

    // Output: 
    // AtEndOfLine : false 
    // String returned : Hello this is the first line of text file. 
    // AtEndOfLine : true
</script>

Continue to next tutorial: Javascript FSO textstream Object AtEndOfStream property to learn how to check whether the textstream reader is at the end of stream.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.