i need to get string by using Line-number as i have two files . the first is containing the line numbers and the second containing the text it self like this
File1 is for line number
   5
   4
   1 
   7
   2
   3
File2 is for the text i need it
-138.84 148.007
-155.57 141.28
-138.173    147.832
-135.094    134.222
-139.843    137.315
-138.619    149.688
-149.256    146.325
-125.212    145.902
-116.355    141.826
the result should be a file containing
-139.843    137.315
-135.094    134.222
-138.84 148.007
-149.256    146.325
-155.57 141.28
-138.173    147.832
how can i start please as i searched a lot but found method that got line number for string not vica versa
i tried this code
fp = open("file1","r")
listt= [] 
lines = []
for line in fp.readlines():
    listt.append(line)
for i in listt:
    print(i)
    x = linecache.getline('file2.txt', i)
    print(x)    
    lines.append(x)
#print(lines)
but got
    Traceback (most recent call last):
  File "get-text.py", line 12, in <module>
    x = linecache.getline('file2.txt', i)
  File "/usr/lib/python3.6/linecache.py", line 17, in getline
    if 1 <= lineno <= len(lines):
TypeError: '<=' not supported between instances of 'int' and 'str'
