title: Change content of binary file
body: <p>I want to change the content of a (large) binary file without reading and writing the whole file content. This is what I tried out:</p>
  
  <pre><code>#!/usr/bin/env tclsh
  set f [open MyFile.txt w+]
  fconfigure $f -translation binary
  foreach c [split "MyText is ABC" ""] {
      puts -nonewline $f $c
  }
  seek $f 2 "start"
  foreach c [split "Name" ""] {
      puts -nonewline $f $c
  }
  close $f
  </code></pre>
  
  <p>I create a file and change <em>Text</em> into <em>Name</em>. That works fine.</p>
  
  <p>But if the file already exists and I want to change <em>Text</em> into <em>Name</em> with the following program</p>
  
  <pre><code>#!/usr/bin/env tclsh
  set f [open MyFile.txt w+]
  fconfigure $f -translation binary
  seek $f 2 "start"
  foreach c [split "Name" ""] {
      puts -nonewline $f $c
  }
  close $f
  </code></pre>
  
  <p>it doesn't work. The reason is that <em>open filename w+</em> truncates the file. Does someone knows how to change the content of an existing binary file?</p>
  
  <p>Thank you in advance.</p>