changed the way it writes to the file