A directory has many sub-directories. Each of the sub-directories have a single text file. The name of the text file is exactly the same as the name of the directory in which it resides (of course, the text files have the .txt extension which the sub-directories don't). I want to read the contents of these text filea. The contents of the text files look like this (all the text files will not have the same contents):

"Google","http://www.google.com"
"Yahoo","http://www.yahoo.com"
"Hotmail","http://www.hotmail.com"
"MSN","http://www.msn.com"


The Form has a DirListBox which lists all the sub-directories. This is how I am trying to read the text files:

Code:
For z = 0 To dir1.ListCount - 1
    'dir1 will have the entire path along with the directory name. I want only the
    'directory name; hence using some String functions to retrieve just the
    'directory name

    DirName = Right(dir1.List(z), Len(dir1.List(z)) - InStrRev(dir1.List(z), "\"))
    FileName = DirName & "\" & DirName & ".txt"

    If (Dir(FileName) <> vbNullString) Then
        Open FileName For Input As #iFile
        Data = Split(Input(LOF(1), 1), vbCrLf)

        'populating the contents of each text file in a TreeView
        'the sub-directory become the Parent nodes
        'the contents of the text files become the Child nodes
    End If
Next
Now what I find is on some occasions, VB generates the following error:

Input past end of file.

pointing to the red line in the above code. When I move the mouse over the variable FileName in the VB IDE, it points to the text file that resides in the 1st sub-directory.

What's causing this error & how do I resolve it?

Please note that NONE of the text files in the different sub-directories are empty. As already mentioned, this error gets generated only sometimes & not always; so I can't comprehend under what circumstances does this error get thrown.