Fixed writing to file issue if no previous file existed.