LPS-44052 Do not leave file handles open