Avoid errors in TextFile

added functionality to filter errors