Well.......you paid a deposit plus rent in advance and signed the tenancy agreement which does make you liable to a large extent. The only thing in your favour is that you didn't take possession of the flat (I assume) i.e. you don't have any keys to it. I could see a possible legal argument that the contract is frustrated because it wasn't fulfilled but it's a bit dodgy ground to be honest.
If you've told the agent that you no longer want the flat then they have to remarket it and I think you'd be liable for rent and any other costs (advertising, credit checks etc) before a new suitable tenant moved in.
The deposit has to be protected these days in a government approved scheme. I'm not sure the agent can simply hold on to any part of the deposit as a punitive measure, any deductions would have to be set against actual costs incurred. I think the automatic non return of a deposit would be an unfair term and legally challengeable.
It really depends on how long, and what costs are involved, in finding a new tenant.