Write to Text File | MuleSoft Documentation
# Write to Text File
_Write to Text File_ writes text to a plain text file, with `.txt` as the only supported file format. You can specify if you want _Write to Text File_ to overwrite existing text in a file or create a new file.
## Properties
**File Operation Settings:**
  * **Add new line** Specify here whether a new line should be added after the new text.
  * **Create if file does not exist** Specify here whether a new file should be created if the specified file does not exist. This option prevent the _Workflow_ from ending with an error message if the file does not exist.
  * **Directory path** Enter the path to the directory where the file to be written to is stored. You can specify an absolute or relative path. If a relative path is used, then the path refers to a storage location relative to the _Base Path_ variable.
  * **File name** Enter the name of the file that is to be written.
  * **Overwrite file content** Specify here whether the whole content of the destination file is to be deleted before writing. This option can be used if you want the specified file to contain only the text that is to be written. If this option is not selected, the new text will be appended at the end of the existing text.
  * **Text to write** Specify here the text that is to be written.


Other Properties that are the same in all action steps are described in the section on **Common Properties**. For reasons of clarity they are not shown here.
## Inbound Variables
**Directory path** Enter the path to the directory where the file to be written to is stored. You can specify an absolute or relative path. If a relative path is used, then the path refers to a storage location relative to the _Base Path_ variable.
**File name** Enter the name of the file that is to be written.
**Text to write** Specify here the text that is to be written.
## Outbound Variables
**Text to write** The _Write to Text File.Text to write_ provides the text that is to be written.
**IsWritten** The _Write to Text File.IsWritten_ variable indicates whether the text could be written to the file or not (True/False).
**File name** The _Write to Text File.File Name_ variable provides the name of the file that is to be written.
**Directory path** The _Write to Text File.Directory Path_ variable provides the path used.
## Wizard
  * **Directory path** Specify the path here to the file that is to be written. You can create an absolute path or a path relative to the _Base Path_. The initial value is %STWS_BASEPATH%. Select an existing path. You can also insert variables from the _Workflow_ in order to construct the path. To do so, click on the pin and select one of the available variables.


  * **File name** Enter the name of the file that is to be written. You can also insert a variable from the Workflow as the _File Name_. To do so, click on the pin and select one of the available variables.
  * **Text to write** Enter the text that is to be written. You can also insert a variable from the Workflow as the _Text to write_. To do so, click on the pin and select one of the available variables.
  * **Overwrite content with text** Specify here whether the whole content of the destination file is to be deleted before writing. This option can be used if you want the specified file to contain only the text that is to be written. If this option is not selected, the new text will be appended at the end of the existing text.
  * **Add a new line after text** Specify here whether a new line should be added after the new text.
  * **Create file if it does not exist** This option determines whether a new file should be created if the specified file does not exist. This option prevents the _Workflow_ from ending with an error message if the file does not exist.
  * **Encoding** The encoding to use when writing the file. Includes Shift-JIS and EUC-JP for Japanese support. Specify a valid encoding type if the one you need is not in the list.