c++ program for counting characters in a file as efficiently as possible