The (old) oil will remain in the filter until the vacuum is broken, by loosening the lid. If you drained/refilled the crankcase, then loosened and changed the filter, you would've introduced the dirty oil into the fresh oil.
I loosen the filter as the very first thing, allowing it to drain into the crankcase, then simultaneously evacuating the crankcase by siphoning the oil out.
Upon refilling, I like to pour at least a quart/litre of oil into the filter housing, then fit the filter and continue pouring oil over it. This saturates the filter, reducing the amount of time it takes for the engine to acheive oil pressure.
1957 Austin-Healey 100/6 Wine Red
1961 McCulloch R1 go-kart Screaming Yellow
1999///M Rdstr Cosmos Black Eurosport Twinscrew S/C
1999///M Coupe Estoril Blue Eurosport Twinscrew S/C
2001///M Rdstr Steel Gray
2011 X5 35i Sport Deep Sea Blue/Cinnamon