it's better to write functions with stream argument to read and write into variables. Cause your code just duplicate STL stream methods