read and write history file