· Jul 1, 2019

Open a text file in Windows - Append to existing log file



I try to open an existing log file and append to it. In Windows I use Open file:(NRW):1. I would expect it to append to the file, but each time I execute the code I get only the new entries, the prior file content is lost.


What is the proper syntax top open a file in "Append" mode?


I will deploy this code in Linux. Is there a different syntax to open a file in Linux versus Windows?




Oliver Wilms

Discussion (1)1
Log in or sign up to continue

The "N" parameter always creates a new file. If you want to open a file (optionally creating it if it doesn't exist), use "E" instead,  and if you intend to Append to it, include the "A" parameter: open file:("EWA"):1. You don't need the "R" parameter unless you intend to read from it using the same device.

Depending on your Cache configuration, you may not even need the "E" parameter. The default behavior in my Windows installation is to create the file if it doesn't exist, with or without the "E" parameter (the documentation refers to "E" as  "UNIX-only", FYI).