Fixed connection not closing on wrong file