title: ReadAll() Method from FSO doesn't complete text file
body: <p>I'm trying to read a text file at once, into a string, to search for a value that I know that exists inside. I'm using the FSO Method (ReadAll()), but the Instr() function doesn't find that value. I think he is importing just a part of the file.</p>
  <pre><code>Sub read_File_At_once_FSO()
  
  On Error Resume Next
  Dim objFileSystemObject As Object
  Dim strFileContent As String
  Dim RowsInFile  As Long
  'Dim ColsInFile  As Long
  Dim FileSize    As Long 'in bytes
  Dim InStrPos    As Long
  Dim strFullPath As String
  
  
      strFullPath = &quot;G:\Fusao de Clientes\PRD\IMP_ID1056001_J.TXT&quot;
      
      ' Use late binding throughout this method to avoid having to set any references.
      Set objFileSystemObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
      strFileContent = objFileSystemObject.OpenTextFile(strFullPath).readall()
      
      
          
                  ' We have a matched string.
                  InStrPos = InStr(1, strFileContent, &quot;0005790306&quot;, vbTextCompare)
      
                  If InStrPos &gt; 0 Then
                      
                      'get FileLen
                      FileSize = FileLen(strFullPath)
                      
                      'Get the number of lines inside the file
                      With CreateObject(&quot;vbscript.regexp&quot;)
                          .Global = True
                          '.Pattern = &quot;\b&quot; &amp; varStrings(lngIndex) &amp; &quot;\b&quot;     'By using word boundary (\b), you can specify in the regex pattern that you are searching for complete word(s).        '&quot;\r\n&quot;       '  or .Pattern = &quot;\n&quot;
                          .Pattern = &quot;\r\n&quot; 'vbCrLf               '.Pattern = &quot;\n&quot; ' vbLf, Unix style line-endings
                          RowsInFile = .Execute(strFileContent).Count + 1
                      End With
                      
                      
                      
                      
                  End If
              
         
          Set objFileSystemObject = Nothing
  On Error GoTo 0
  
  
  End Sub
  </code></pre>
  <p>I dont know how to atach the file for you to test it.</p>
  <p>When I try to read with the code below, I'm geting the 'Run Time Error 62 : Imput past end of file'.</p>
  <pre><code>Function read_File_At_once()
  
  Dim strFilename As String: strFilename = &quot;G:\Fusao de Clientes\PRD\IMP_ID1056001_J.TXT&quot;
  Dim strFileContent As String
  Dim iFile As Integer: iFile = FreeFile
  Open strFilename For Input As #iFile
  strFileContent = Input(LOF(iFile), iFile)
  
      'Get the number of lines inside the file
      With CreateObject(&quot;vbscript.regexp&quot;)
          .Global = True
          '.Pattern = &quot;\b&quot; &amp; varStrings(lngIndex) &amp; &quot;\b&quot;     'By using word boundary (\b), you can specify in the regex pattern that you are searching for complete word(s).        '&quot;\r\n&quot;       '  or .Pattern = &quot;\n&quot;
          .Pattern = &quot;\r\n&quot; 'vbCrLf               '.Pattern = &quot;\n&quot; ' vbLf, Unix style line-endings
          RowsInFile = .Execute(strFileContent).Count + 1
      End With
  
  
  Close #iFile
  End Function
  </code></pre>
  <p>Can anyone help please?</p>