This question is a bit of a two parter. The question is essentially, "how do I read and write strings from a file?" which can of course be broken into the read question and the write question. As it happens, both of those are duplicates of (separate) questions.
I considered voting to close the question as too broad, but I don't think it's actually very broad at all: the OP is asking about two actions, but they're essentially two sides of the same coin (heck, we even have a term, "I/O" that combines them).
I also considered marking it as a duplicate of one and adding a comment to point to the other, but that didn't seem right. Which do I pick as the dupe?
I posted a comment on the question pointing to the two dupes, but I didn't close to vote. Was there a better course of action?