swapped from ints to size_t for position in stream