figured out fsteam instead of alternating i/ofstream