Flush instead of open and close in collect

collectData.py was previously opening and closing the file repeatedly.
Now it flushes appropriately. Makes more sense.
More data points will now be generated