Clearer error message, switched to open() for reading files