Fix crash when reading from empty history file

Closes #561