fixed missing file close in readFile function