move file handling locally. For #1295.