Add empty_directory method to clear directory when finished; simplify Dir.foreach lines (51, 57)