Refactored TextFileHandler.cs