Counting the number of lines in a file

Main.java:

import java.io.*;
 
public class Main {
   public static void main(String args[]) {
      if (args.length != 1) {
         System.err.println("Usage: java Main <textfile>");
         System.exit(1);
      }
 
      try {
         BufferedReader br = new BufferedReader(new FileReader(args[0]));
         int total = 0;
         while (br.readLine() != null) total++;
         System.out.println(total);
      }
      catch(FileNotFoundException e) {
         System.err.println(e);
      }
      catch(IOException e) {
         System.err.println(e);
      }
   }
}