changed standard try-catch with wrongly placed close() statement into
try-with-resources