Fixed bug with writing out report