improve error handing on bad files