title: Get number of columns using OpenCSV
body: <p>I have a txt file and I want to count the number of columns. (I use openCSV)</p>
  
  <pre><code>public class demoTable {
      public demoTable(){
           read();
          JOptionPane.showMessageDialog(null, "number of columns inside file: " + getNumberOfColumnsFromFile(), null, JOptionPane.INFORMATION_MESSAGE);
      close();
      }
  
      private void read(){
      try {
          this.fileInputStream = new FileInputStream("D:\\Book3.txt");
          UTF8_CHARSET = StandardCharsets.UTF_8.newDecoder();
          UTF8_CHARSET.onMalformedInput(CodingErrorAction.REPLACE);
          this.fileReader = new InputStreamReader(this.fileInputStream, UTF8_CHARSET);
          this.reader = new CSVReader(this.fileReader, '\t');
      } 
      catch (FileNotFoundException ex) {
          Logger.getLogger(VJTable.class.getName()).log(Level.SEVERE, null, ex);
      }
      }
  
      private int getNumberOfColumnsFromFile(){
      //Estimating number of rows from file (Googled that).
      this.numberOfColumns = 0;
      try {
          while( (this.nextLine = this.reader.readNext()) != null){
              this.numberOfColumns++;
          }
      } 
      catch (IOException ex) {
          Logger.getLogger(VJTable.class.getName()).log(Level.SEVERE, null, ex);
      }
      return this.numberOfColumns;
     }
  
     private void close(){
      try {
          this.fileInputStream.close();
          this.fileReader.close();
          this.reader.close();
      }
      catch (IOException ex) {
          Logger.getLogger(VJTable.class.getName()).log(Level.SEVERE, null, ex);
      }
      }
  }
  </code></pre>
  
  <p>Unfortunately, the <code>getNumberOfColumnsFromFile()</code> method returns the number of rows instead of columns. Could you please tell me what I don't do well in here? Thank you in advance.</p>