Hello, in this video, we are going to cover writing to the file. Remember, you need to open the file using the F open command and you need to always close it. One more change you're gonna make is instead of putting an R here, we're gonna put it before, right, because we call write to if we don't specify the exact permission. And now, as you can see, there's nothing in here and to white is really simply put F, right. And first of all, it's best for the file. So dollar fall.
Next is the data. This could be a variable that has some data inside of it for direct strings on say, Hello. And then what I want to do on a new line is put f right dollar file, and I'm going to put line, so if we save that, reload it and we get Permission denied knowing Don't do anything Okay, so what has happened? So we've opened it we've given it right permissions which looks okay to me froid experts want to be prompt to want to be resource share this right here but that seems to be a problem on here failed to open stream Permission denied. So things like let me show this in Finder. Okay so some reason you may need to edit the permission depending on what computer you are using this.
Like what OSC might be slightly different Sure, commission let's do read and write read. Okay. So let's try that now. There we go. If we open it. So look f right.
Dollar file. Yes. Hello. Well, that should be okay. f close. We've closed it as well.
There we go. some reason it didn't update. There we go. So what's happened? We wanted two different lines. And to actually add the lines, we need to put backslash n, which is the new line character.
So any format for me to specifically specify for going to it there we go. So that's just another thing to bear in mind. It actually overrides the content. So what I want you to do as an ad Extra task is you know, think about how you can sort of overcome the fact that it is over writing. So that is it. If you have any questions, feel free to pop me a message.
And as usual, I look forward to seeing you in the next video.