Fixed output writer to handle arbitrary localisations. need to check error propagations