Ailing US retailer A&P has filed for bankruptcy in a bid to fully restructure a business loaded with debt and hit by competition.