added file writing to demohstorecorrect