fixed out of bounds in history and stats file reading