Now writes data to file