Fixed uninitialized char array and changed fclose to pclose