switched everything to use fstream instead of unistd