Keep FILE* pointers in extract and replace functions
reorganize functions