If we can't open a file, raise an error rather than segfault.