add try catch finnally to ensure bw.close();