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

int main(void)
{
  FILE *fp, *nf;
  char ch;

  if ((fp = fopen("origpic", "r")) == NULL)
  {
    fprintf(stderr, "Can't open file\n");
    exit(EXIT_FAILURE);
  }

  if ((nf = fopen("newpic", "w+")) == NULL)
  {
    fprintf(stderr, "Cannot create new file\n");
    exit(EXIT_FAILURE);
  }

  while ((ch = getc(fp)) != EOF)
  {
    if (ch != '\n')
    {
      putc(ch, nf);
      putc(' ', nf);
    }
    else putc('\n', nf);
  }

  fclose(fp);
  fclose(nf);

  return 0;
}
