You can't use sizeof(string) to determine the space needed on the file to store a string. You should use a fixed size space for that - there would be several different possible choices here, but you do need to use some method to define how large your string is.
Also, it is not absolutely necessary to use a fixed size record to be able to random access the file - however, if the records are NOT all the same size, then you would need some other way (such as an array of integer indicating "which record is where in the file").
--
Mats