added file handle closing to helper