I changed nb1 and nb2 into lists and appended the column values to each adding '\n' so they are written on a new line. The output file has a single column with the values from column 1 on top of the values from column 2. This approach works well for the most part but if you are dealing with really large files this method uses a lot of memory. If that is an issue you can form your output file in two passes writing first the first column to file and then the second column.
nb1 = []
nb2 = []
with open('input.txt','r') as input_data:
for line in input_data:
column = line.strip().split()
nb1.append(column[0]+'\n')
if len(column) == 2:
nb2.append(column[1]+'\n')
with open('output.txt','w') as f:
f.writelines(nb1)
f.writelines(nb2)
If you wanted the second element in each row under the first element you could use this simpler more memory friendly syntax.
with open('input.txt','r') as input_data:
with open('output.txt','w') as f:
for line in input_data:
column = line.strip().split()
f.write(column[0]+'\n')
f.write(column[1]+'\n')