If you are opening a file for read and write access use "rb+" or "wb+". Seeking and subsequent read/write will then work fine. Without the "b", Windows opens the file in its "text" mode. Don't seek on files opened in "text" mode.