added \r instead of \n for file writing