little cleanup, use uncurry
handle exceptions opening files