require(token.transfer(beneficiary, token.balanceOf(this)));
where token is the ERC20 token you're transferring. E.g.:
interface IERC20Token {
function transfer(address, uint256) external returns (bool);
function balanceOf(address) external returns (uint256);
}
contract Foo {
IERC20Token token = IERC20Token(0x123abc...);
function doit(address beneficiary) public {
require(token.transfer(beneficiary, token.balanceOf(this)));
}
}