Updated to match API change to StringBuffer which now uses write() instead of add().