I'm working on a dictionary implementation in C, which requires me to read in a multiline file with the word and definitions. I can get the file to read in correctly, however instead of EOF, a full stop . is used to mark the end of the file. I have tried to stop the program from reading the file once it reaches the . but to no avail. 

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

#define MAX_WORD_SIZE   40
#define MAX_DESC_SIZE  200

int d_read_from_file(const char * filename){
    char dbuffer[MAX_WORD_SIZE+MAX_DESC_SIZE+2];
    char word[MAX_WORD_SIZE+1];
    char meaning[MAX_DESC_SIZE+1];
    int i = 0;

    FILE *file = fopen(filename, "r");
    if (file == 0)
    {
        printf("Could not open file\n");
        return 0;
    }
     while((fgets(dbuffer, sizeof(dbuffer), file))) {
        if (strcmp(word, ".") == 0) {
            break;
        }
        sscanf(dbuffer, "%s %[^\n]",word, meaning);
        printf("%s\n", word);
        printf("%s\n", meaning);
    } 
    return 1;
           /* d_read_from_file(filename);*/
}

int main(int argc, char ** argv)
{
    int i;
    for (i=1; i<argc; i++)
        d_read_from_file(argv[i]);
}

```

I know the code looks a bit messy right now, but I was just trying to get it to stop once it hit the . character.

Here is an example of the input: 

```
computer Electronic device for processing data according to instructions
playground Area of outdoor play or recreation
plateau Land area with high, level surface
aardvark Unfriendly, nocturnal mammal native to Africa
.

```

And the output I get from the code I have written:

```
computer
Electronic device for processing data according to instructions
playground
Area of outdoor play or recreation
plateau
Land area with high, level surface
aardvark
Unfriendly, nocturnal mammal native to Africa
.
Unfriendly, nocturnal mammal native to Africa

```

It appears to continue once more around the loop and using . as the word and then printing out the last meaning to be read in. Any ideas on how to fix this? Also if there is a more efficient way of doing what I am doing then also let me know.