use exceptions for IO errors
initialize buffer with calloc()