WOLFRAM

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)Summary of the most common use cases

Write a string to a temporary file:

Print the file:

Delete the temporary file:

Start the system shell process:

Out[1]=1

Write a command into the shell process:

Read one line from the shell output:

Out[3]=3

Scope  (2)Survey of the scope of standard use cases

Open a stream:

Write a line into the file:

Close the stream:

Print the contents that were written:

Create a temporary file:

Out[1]=1

Write a line of text:

Out[4]=4

Both lines were written:

Delete the temporary file:

Properties & Relations  (1)Properties of the function, and connections to other functions

WriteLine inserts line breaks after each string it writes:

Out[1]=1
Out[4]=4

WriteString does not insert line breaks automatically:

Out[8]=8

Delete the temporary file:

Wolfram Research (2014), WriteLine, Wolfram Language function, https://reference.wolfram.com/language/ref/WriteLine.html (updated 2016).
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).

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.

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

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

BibTeX

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

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

BibLaTeX

@online{reference.wolfram_2025_writeline, organization={Wolfram Research}, title={WriteLine}, year={2016}, url={https://reference.wolfram.com/language/ref/WriteLine.html}, note=[Accessed: 02-June-2025 ]}

@online{reference.wolfram_2025_writeline, organization={Wolfram Research}, title={WriteLine}, year={2016}, url={https://reference.wolfram.com/language/ref/WriteLine.html}, note=[Accessed: 02-June-2025 ]}