title: Why does an output string show data I never wrote?
body: <p>I'm writing a program that encrypts a file by adding 10 to each character. Somehow a portion of the programs working directory is being printed to the file, and I have no idea why.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
      int main(void){
          FILE *fp;
          fp=fopen("tester.csv","r+");
          Encrypt(fp);      
          fclose(fp);
      }
  
      int Encrypt(FILE *fp){
          int offset=10;
          Shift(fp, offset);
      }
      int Decrypt(FILE *fp){
          int offset= -10;
          Shift(fp, offset);
      }
      int Shift(FILE *fp, int offset){
          char line[50],tmp[50], character;
          long position;
          int i;
          position = ftell(fp);
          while(fgets(line,50,fp) != NULL){
              for(i=0;i&lt;50;i++){
                  character = line[i];
                  character = (offset+character)%256;
                  tmp[i] = character; 
                  if(character=='\n' || character == 0){break;}                
              }
              fseek(fp,position,SEEK_SET);
              fputs(tmp,fp);
              position = ftell(fp);
              fseek(stdin,0,SEEK_END);
          }
        }
  </code></pre>
  
  <p>the file originally reads</p>
  
  <pre><code>this, is, a, test
  i, hope, it, works!
  </code></pre>
  
  <p>after the program is run:</p>
  
  <pre><code>~rs}6*s}6*k6*~o}~
  /alexio/D~6*y|u}+
  k6*~o}~
  /alexio/D
  </code></pre>
  
  <p>where users/alexio/Desktop is part of the path. How does this happen???</p>