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


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


writes "string" to an external process proc.


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


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:

Introduced in 2014
Updated in 2016