Revert "Do not use buffered writer, it seems to cause long timeouts"

This reverts commit d6fc3b1c867df12513e1e395dec13b89eea99434.
Better approach for handling buffered writer