WriteLine

WriteLine["file","string"]

writes "string" to a file, followed by a newline.

WriteLine[stream,"string"]

writes "string", followed by a newline, to the specified output stream.

WriteLine[proc,"string"]

writes "string" to an external process proc.

Details

  • WriteLine will open a file for writing, erasing all existing data, if it is not already open.
  • WriteLine[File["file"],] is also supported.

Examples

open allclose all

Basic Examples  (2)

Write a string to a temporary file:

Print the file:

Delete the temporary file:

Start the system shell process:

Write a command into the shell process:

Read one line from the shell output:

Scope  (2)

Open a stream:

Write a line into the file:

Close the stream:

Print the contents that were written:

Create a temporary file:

Write a line of text:

Both lines were written:

Delete the temporary file:

Properties & Relations  (1)

WriteLine inserts line breaks after each string it writes:

WriteString does not insert line breaks automatically:

Delete the temporary file:

Wolfram Research (2014), WriteLine, Wolfram Language function, https://reference.wolfram.com/language/ref/WriteLine.html (updated 2016).

Text

Wolfram Research (2014), WriteLine, Wolfram Language function, https://reference.wolfram.com/language/ref/WriteLine.html (updated 2016).

CMS

Wolfram Language. 2014. "WriteLine." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/WriteLine.html.

APA

Wolfram Language. (2014). WriteLine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WriteLine.html

BibTeX

@misc{reference.wolfram_2024_writeline, author="Wolfram Research", title="{WriteLine}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/WriteLine.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_writeline, organization={Wolfram Research}, title={WriteLine}, year={2016}, url={https://reference.wolfram.com/language/ref/WriteLine.html}, note=[Accessed: 21-November-2024 ]}