fix memory leaks in readfile function
added 2 header