added permisions, added buffered writer, added a couple of tests