misc: Improve text file apis