Closes the history file reader correctly

The ReversedLinesFileReader is not closed after use. This patch implements the standard try-catch-finally pattern to  address that.