Handle buffer sizes and file read errors more gracefully