added write file method to directory.rb