title: What is causing 'Index was outside the bounds of the array' error?
body: <p>What is causing 'Index was outside the bounds of the array' error? It can't be my file, defianetly not. Below is my code:</p>
  
  <pre><code> Sub pupiltest()
  
      Dim exitt As String = Console.ReadLine
      Do
          If IsNumeric(exitt) Then
              Exit Do
          Else
             'error message
          End If
      Loop
  
      Select Case exitt
          Case 1
          Case 2
          Case 3
      End Select
  
      Do
          If exitt = 1 Then
              pupilmenu()
          ElseIf exitt = 3 Then
              Exit Do
          End If
      Loop
  
      Dim score As Integer
      Dim word As String
      Dim totalscore As Integer = 0
  
      'If DatePart(DateInterval.Weekday, Today) = 5 Then
      'Else
      '    Console.WriteLine("You are only allowed to take the test on Friday unless you missed it")
      '    pupiltest()
      'End If
  
      Dim founditem() As String = Nothing
      For Each line As String In File.ReadAllLines("F:\Computing\Spelling Bee\stdnt&amp;staffdtls.csv")
          Dim item() As String = line.Split(","c)
          founditem = item
      Next
  
      Dim stdntfname As String = founditem(3)
      Dim stdntsname As String = founditem(4)
      Dim stdntyear As String = founditem(5)
      Console.Clear()
  
      If founditem IsNot Nothing Then
          Do
              If stdntyear = founditem(5) And daytoday = founditem(6) Then
                  Exit Do
              ElseIf daytoday &lt;&gt; founditem(6) Then
                  Console.WriteLine("Sorry you are not allowed to do this test today. Test available on " &amp; item(6).Substring(0, 3) &amp; "/" &amp; item(6).Substring(3, 6) &amp; "/" &amp; item(6).Substring(6, 9))
                  Threading.Thread.Sleep(2500)
                  pupiltest()
              ElseIf stdntyear &lt;&gt; founditem(5) Then
                  Console.WriteLine("Year not found, please contact the system analysts")
                  Threading.Thread.Sleep(2500)
                  pupiltest()
              End If
          Loop
      End If
  
      For Each line As String In File.ReadAllLines("F:\Computing\Spelling Bee\testtests.csv")
          Dim item() As String = line.Split(","c)
          Dim mine As String = String.Join(",", item(2), item(3), item(4), item(5), item(6))
          For i As Integer = 1 To 10
              Console.WriteLine(i.ToString &amp; "." &amp; item(1))
              Console.Write("Please enter the word: ")
              word = Console.ReadLine
              If word = Nothing Or word &lt;&gt; item(0) Then
                  score += 0
              ElseIf word = item(0) Then
                  score += 2
              ElseIf word = mine Then
                  score += 1
              End If
          Next
  
          If score &gt; 15 Then
              Console.WriteLine("Well done! Your score is" &amp; score &amp; "/20")
          ElseIf score &gt; 10 Then
              Console.WriteLine("Your score is" &amp; score &amp; "/20")
          ElseIf score Then
          End If
      Next
  
      Using sw As New StreamWriter("F:\Computing\Spelling Bee\stdntscores", True)
          sw.Write(stdntfname, stdntsname, stdntyear, score, daytoday, item(7))
          Try
          Catch ex As Exception
              MsgBox("Error accessing designated file")
          End Try
      End Using
  
  
  
      End
  End Sub
  </code></pre>
  
  <p>All help is highly appreciated,</p>