title: Reading CSV file in Java: extra line
body: <p>I'm reading this CSV:</p>
  
  <pre><code>A;San Antonio;Tercer Barrio
  B;Camino de la Miranda;Campus
  C;San Lázaro;Cementerio
  E;Cristo;H. Río Carrión
  H;H. San Telmo;H. Río Carrión
  M;Plaza de León;Monte el Viejo
  P;Allende el Río;Campus
  </code></pre>
  
  <p>and I want to populate a SQLite database in Android using this method:</p>
  
  <pre><code>private void insertRoutes(SQLiteDatabase db) {
    try {
       BufferedReader reader = new BufferedReader(
               new InputStreamReader(context.getAssets().open(SQL_FILE_ROUTES)));
  
       String query =
               "insert into routes (name, rfrom, rto) values (?, ?, ?)";
  
       db.beginTransaction();
       SQLiteStatement stmt = db.compileStatement(query);
       String line;
  
       while ((line = reader.readLine()) != null) {
          String[] dic = line.split(";");
          stmt.bindString(1, dic[0]);
          stmt.bindString(2, dic[1]);
          stmt.bindString(3, dic[2]);
          stmt.execute();
          stmt.clearBindings();
       }
       db.execSQL(query);
       db.setTransactionSuccessful();
  
    } catch (IOException e) {
       e.printStackTrace();
    } finally {
       db.endTransaction();
    }
  }
  </code></pre>
  
  <p>It "works" and my database get populated, but with and extra row. This is the result when I check the sqlite database:</p>
  
  <pre><code>sqlite&gt; select * from routes;
  1|A|San Antonio|Tercer Barrio
  2|B|Camino de la Miranda|Campus
  3|C|San Lázaro|Cementerio
  4|E|Cristo|H. Río Carrión
  5|H|H. San Telmo|H. Río Carrión
  6|M|Plaza de León|Monte el Viejo
  7|P|Allende el Río|Campus
  8|||
  </code></pre>
  
  <p>There are 8 rows, but the CSV file has just 7 lines. What I'm doing wrong?
  Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have checked the file. It has 7 lines:</p>
  
  <pre><code>wc default_android_routes.csv 
  7  25 198 default_android_routes.csv
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Like @flopo has said, <code>db.execSQL(query);</code> was the guilty. Just remove it.</p>