replace calls to gets with fgets