Q:

Java Writing to a file: does not write to all desired files

I am out of ideas, I've been trying for the whole day to separate one file which has a format of :
AN  Aixas
AN  Aixirivall
AN  Aixovall
AN  Andorra la Vella
BR  Salto do Mandira
BR  Salto do Norte
BR  Salto Dollman
BR  Salto Grande
BR  Salto Pilao
...

and so one, into different files by the name of the Country "AA.txt" and to include all the cities in these separate files.  But my program only writes to a certain bunch of files and I cannot figure out why. 
I've tried all the writing files classes - same result. 
Here is the result, all worked but on a certain bunch of files only. 

Here is the code :
package com.fileorganizer;

import java.io. BufferedReader;
import java.io. BufferedWriter;
import java.io. File;
import java.io. FileInputStream;
import java.io. FileNotFoundException;
import java.io. FileWriter;
import java.io. IOException;
import java.io. InputStream;
import java.io. InputStreamReader;

public class File2 implements Cloneable {
    static InputStream fis = null;
    static BufferedReader br = null;
    static String state = "";
    static String tmp = "";
    static File file = null;
    static FileWriter fw = null;
    static BufferedWriter bw = null;

    public static void main(String[] args) {
        int a = 0;

        try {
            fis = new FileInputStream(
                    new File(
                            "/Users/Mihail/Documents/WorkSpace/Parse-Starter-Project-1.8.2/ParseStarterProject/res/raw/cities.txt"));
            br = new BufferedReader(new InputStreamReader(fis));
            String line = null;

            while ((line = br.readLine()) ! = null) {
                state = line.substring(0, 2);
                if (state.substring(0, 1).matches("^[A-Z]+$")
                        && state.substring(1, 2).matches("^[A-Z]+$")
                        && ! tmp.equals(state)) {
                    file = new File(
                            "/Users/Mihail/Documents/WorkSpace/Parse-Starter-Project-1.8.2/ParseStarterProject/res/raw/countriesFolder/"
                                    + state + ".txt");
                    fw = new FileWriter(file.getAbsoluteFile());
                    bw = new BufferedWriter(fw);
                    tmp = state;
                }
                bw.write(line.substring(3) + "\n");
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br ! = null)
                    br.close();
            } catch (Exception ex) {
            }
        }
    }
}

I am really sorry for such a dumb question.  Please help

A:

You don't close bw anywhere, so the contents in the BufferedWriter's buffer are lost.