fix crash when opening invalid txt files