generalizing file management functions