Fix: closing wrong file handler