use tofile instead of todir