To go to the start of an IOStream, you have to do seek(io, 0). Why is this? I just spent about 30 minutes trying to debug an error caused by using seek(io, 1) instead.
              
              
              1 Like
            
            
          It’s just the standard convention for file positions across virtually all languages: refer to an offset relative to the start of the file (and hence be zero-based).
This convention is used even in languages like Matlab (fseek), Fortran (fseek), R (seek), and Lua (file::seek) that are otherwise 1-based by default, so it would be weird for Julia to differ.
              
              
              10 Likes
            
            
          Thanks Steven, that seems reasonable.
Perhaps a mention of this would be handy in the docs for seek.
              
              
              2 Likes
            
            
          Sure, you can do it yourself by opening a pull request for Julia! 
Note also that to go to the beginning of the stream you can use seekstart.
              
              
              6 Likes