Fixed error in flushTheBuffer