title: Reading and writing from a csv file
body: <pre><code>Structure TownType
      Dim Name As String
      Dim County As String
      Dim Population As Integer
      Dim Area As Integer
  End Structure
  
  Sub Main()
      Dim TownList As TownType
      Dim FileName As String
      Dim NumberOfRecords As Integer
      FileName = "N:\2_7_towns(2).csv"
  
      FileOpen(1, FileName, OpenMode.Random, , , Len(TownList))
      NumberOfRecords = LOF(1) / Len(TownList)
      Console.WriteLine(NumberOfRecords)
      Console.ReadLine()
  </code></pre>
  
  <p>There are only 12 records in the file but this returns a value of 24 for number of records. How do I fix this?</p>
  
  <p>Contents of csv file:</p>
  
  <pre><code>Town, County,Pop, Area
  Berwick-upon-tweed, Nothumberland,12870,468
  Bideford, devon,16262,430
  Bognor Regis, West Sussex,62141,1635
  Bridlington, East Yorkshire,33589,791
  Bridport, Dorset,12977,425
  Cleethorpes, Lincolnshire,31853,558
  Colwyn bay, Conway,30269,953
  Dover, Kent,34087,861
  Falmouth, Cornwall,21635,543
  Great Yarmouth, Norfolk,58032,1467
  Hastings, East Sussex,85828,1998
  </code></pre>