Fix possible leaking of file handle

Signed-off-by: Tomas Hozza <thozza@redhat.com>