My PrintWriter will write (some) data to disk if the file written is very large but none if it is small. The StringBuffer writes to screen ok with a small file, but won't write all of a large file, unless PrintWriter is commented out. (Small test file 355b, large 839k).
The output is being buffered by the BufferedWriter, and probably by the OS, too. After the out.print(), you'll need to close the file, so everything is flushed to disk. Call out.close(), and everything should be fine.