title: SWI-Prolog write to file
body: <p>I saw the below threads and they are very useful and related to my problem </p>
  
  <p><a href="https://stackoverflow.com/questions/4736384/writing-in-file-swi-prolog-windows">Writing in file | Swi-Prolog | Windows</a>\</p>
  
  <p><a href="https://stackoverflow.com/questions/10857202/prolog-insert-modify-and-delete-facts-on-a-separated-database-text-file">Prolog insert, modify and delete facts on a separated database text file</a></p>
  
  <p>I tried to use tell, told see , seen to read write from text files but I have the same result nothing is written on the file when (I open it and see that) , and on the read either the system read end_of_file or have an error displayed in a message or on the console 
  Below is some samples of my work :</p>
  
  <pre><code>start1:-
      open('output.txt',write,OS),
      X = 'Hi all',
      write(OS,X),
      close(OS),
      open('output.txt',read,OS2),
      read(OS2,Input).
  
  
  start1:-
      absolute_file_name('X.data',Abs),
      open(Abs,write,Out),
      tell(Abs),
      write('HiAll'),
      told,
      close(Out),
      open(Abs,read,In),
      see('X.data'),
      read(X),
      seen,
      write(X).
  </code></pre>