Added event and fixed bug in process_file