Check that file is valid pointer.
Use calloc instead of malloc.