"А я почти было так написал!" -- sounds absolutely perfect.
"А я почти что было так написал!" -- also quite good. Maybe a bit old-fashioned.