made it write into file directly