what is its advantage over opening and closing? and also i think opening and closing helps sace memory?

I read about RAII, which is actually a very good practice. I was worried about memory consumption(even though it is small amounts).
I also have one question. If one uses new with RAII, is it still necessary to call delete?

When you use an fstream, you shouldn't thinking file. You ought to be thinking stream. You don't open/close streams. You just read/write them.

Like I said before, RAII. If you have an fstream, it should be in a usable and functional state from the start. There are a number of interlocking concepts that support robust design, such as Adam's exception guarantees. Being careless about state doesn't help.

I think it's just plain wrong to have a beginner's tutorial on fstreams that calls open/close on them. You'll be checking for EOF next It's not called the I/O stream library for nothing.