fixing seg faults in open file, memory issues in close file
removing debugging prints