take a look at openAndRead.c