Addressed problem with tmpfile  returning NULL, but doesn't look like there's a way to fix it.