You might want to add objects that automatically free/fclose at the end of the scope but I understand that might be a bit complicated