this fstream stuff can be removed