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.

DetailsDetails

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

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Write a string to a temporary file:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input

Print the file:

In[3]:=
Click for copyable input

Delete the temporary file:

In[4]:=
Click for copyable input

Start the system shell process:

In[1]:=
Click for copyable input
Out[1]=

Write a command into the shell process:

In[2]:=
Click for copyable input

Read one line from the shell output:

In[3]:=
Click for copyable input
Out[3]=
Introduced in 2014
(10.0)