Handle both file handles and file names