clean and flush before reading file