fclose(3) instead of pclose(3) as the latter seems to leak file descriptors