I have the following program in Swift (
print("Enter x: ");
var x = readLine()!
print("x is " + x)
print("Enter y: ");
var y = readLine()!
print("y is " + y)
I found the solution. The command to compile is as follows:
swift myscript.swift < input.txt
There is no need for additional swift code.