Move typedef above prototypes
Remove newlines
Remove explicit cast
Make buffer size larger
Add free() to every erroneous exit
Add fclose() to one erroneous exit
Make the data pointer constant