output to file finally works