[BUG] multi-line input from a piped file using input()
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Bug description
Actual behavior
When I create an input file with multiple lines and call the input() function, I throw an EOF error when reading the second line.
Expected behavior
I'd like to read both lines. This works fine when just using stdin.
Steps to reproduce
main.mojo:
def main():
t: String = input()
print("First string: " + t)
s: String = input()
print("Second string: " + t)
a.in:
hello
world
cmdline: mojo main.mojo < a.in
result:
First string: hello
Unhandled exception caught during execution: EOF
mojo: error: execution exited with a non-zero result: 1
System information
- Provide the system information by running
pixi info.
System
Pixi version: 0.63.1
TLS backend: rustls
Platform: osx-arm64
Virtual packages: __unix=0=0
: __osx=26.2=0
: __archspec=1=m1
Cache dir: /Users/ernest/Library/Caches/rattler/cache
Auth storage: /Users/ernest/.rattler/credentials.json
Config locations: No config files found
Global
Bin dir: /Users/ernest/.pixi/bin
Environment dir: /Users/ernest/.pixi/envs
Manifest dir: /Users/ernest/.pixi/manifests/pixi-global.toml
Workspace
Name: life
Version: 0.1.0
Manifest file: /Users/ernest/repo/life/pixi.toml
Last updated: 17-01-2026 20:58:52
Environments
Environment: default
Features: default
Channels: https://conda.modular.com/max-nightly, conda-forge
Dependency count: 1
Dependencies: mojo
Target platforms: osx-arm64
Prefix location: /Users/ernest/repo/life/.pixi/envs/default
- Provide version information for MAX (includes Mojo) by pasting the output of
pixi list max.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with main.mojo, the a.in two-line input file, and the command mojo main.mojo < a.in. Start from the input() entry point and compare piped-file behavior with interactive stdin. Done means both lines are read and printed without an EOF error; no repository test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100