implemented file reading, memory clean up successful