Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Generally, you read the entire file into an application model at the beginning of your application and write the entire file from your application model at the end of your application. Commented Mar 13, 2023 at 14:53
  • Text files don't allow random access and insertions like this: You can only overwrite characters 1-to-1 (technically since variable-width-encodings like UTF-8 exists you can't even do that reliably). Basically most direct access that you want doesn't work for pure text files. Commented Mar 13, 2023 at 15:02
  • The simplest solution would be to have 1 file per mode instead of one shared one. Then you can simply overwrite that modes file each time. Commented Mar 13, 2023 at 15:03