gave better names and used seekg for reading