fixed more memory leaks, this time in read_file