Fixing some logic issues with writing data files.

Just moving some places where the data array is declared
and how the file is written out.

@jonschlinkert is this what you're looking for? The json files might not be in the correct place.