We don't use FileWriter because the encoding can be platform-specific.  Instead use FileOuputStream and enforce use of UTF-8 by wrapping it in an OutputStreamWriter, or by doing sb.toString().getBytes("UTF-8") below.