Refactoring the duplicate code of the todo file reading.