switched to IOUtils.writeLines with BufferedWriters for simplicity