Been looking in to C and I'm working on a simple program to read a text file, apply a caesar cipher, and write to a new output file. My problem is that the while-loop supposed to build my output string terminates immediately, claiming that the next character is EOF, even when it obviously isn't. Code below:

```
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#define MORD ".mord"

void die(const char *message)
{
  if(errno) {
    perror(message);
  } else {
    printf("ERROR: %s\n", message);
  }

  exit(1);
}

int main(int argc, char *argv[])
{
  if(argc != 3) die("USAGE: dodsmord <filename> <offset>");
  char *infilename = argv[1];
  char *outfilename = strcat(infilename, MORD);
  int offset = atoi(argv[2]);
  char *outstr[1000];
  FILE *infile = fopen(infilename, "r+");
  FILE *outfile = fopen(outfilename, "w+");
  if(infile == NULL) {
    die("Could not open input file");
  }
  if(outfile == NULL) {
    die("Could not open output file");
  }
  int c;
  int i = 0;
  printf("reading input file...\n");
  while(1) {
    c = fgetc(infile);
    printf("c == EOF: %d\n", c == EOF ? 1 : 0);
    printf("EOF: %d\n", EOF);
    printf("c is now: %c\n", c);
    if(c == EOF) break;
    outstr[i] = c + offset;
    i++;
  }
  printf("done reading! writing outstr to outfile...\n");
  fwrite(outstr, sizeof(char), i, outfile);

  printf("closing streams...\n");
  fclose(infile);
  fclose(outfile);

  return 0;
}

```

The output if I run the code on test.txt (which contains exactly "abcdefg" without quotes), I get the output

```
reading input file...
c == EOF: 1
EOF: -1
c is now: �
done reading! writing outstr to outfile...
closing streams...

```