Refactoring generate.rb a bit, pulling file accessor out