Write complete lines by ending each output with "\n": file << name << "\n";. This creates one line per write operation, making files readable by line-oriented tools like grep or text editors.
You can also use endl: file << data << endl;. This adds a newline and flushes the buffer immediately. Use endl when you need guaranteed disk writes (like logging errors), but it's slower than "\n".
For CSV or structured formats, separate fields with delimiters: file << id << "," << name << "," << score << "\n";. Each line becomes a record you can parse back with getline() and string splitting.