fix copy ctor

the constructed object was used as copy source
don't leak file pointer