You are printing the last value only. So you are getting the result only 13.You have to write the value in the for loop.
b = open('new', 'w')
for n in [4, 7, 8, 10, 6, 3, 5, 13]:
if n > 5:
print(n)
b.write(n)
1
solved Writing integers into a new file